It is currently March 28th, 2024, 12:59 pm

Doing several things once text changes in InputText box

Get help with creating, editing & fixing problems with skins
zudzug
Posts: 7
Joined: January 24th, 2020, 5:01 am

Doing several things once text changes in InputText box

Post by zudzug »

Good Morning!

I am trying to do this with an InputText box:
1- Update a $variable$ (works as intended).
2- Update a Webparser and its substrings.
3- Update the same variable again, with more detailed info this time, confirming the webparser did its job.
4- Update the meters associated once this is all done.

I am somehow stuck on step 1. The debug info says the ActionTimer gets called by the InputText box, but I don't see any updates going through.

Here's my (probably shoddy) code. I've tried a lot of things and I might have derailed a bit from the proper etiquette with Rainmeter. I have condensed the important stuff in a single excerpt for your viewing pleasure.

Thanks a lot and have a great "night". (I'm gonna go get some sleep)

Code: Select all

[Rainmeter]
Update=-1
DynamicVariables=1
Author=Zudzug

DisplayName=Test
Address=louvre, paris, france
LocationLat=45.689
LocationLong=-102.0445
lang=en
SettingsTextColor1=0,0,0
SettingsTextColor2=255,255,255

AddressURL=https://nominatim.openstreetmap.org/search/#Address#?format=json&limit=1&accept-language=#lang#
;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureLocation]
Measure=WebParser
URL=#AddressURL#
RegExp=(?siU).*"lat":"(.*)","lon":"(.*)","display_name":"(.*)".*
FinishAction=[!Log "Address fetch finished." Debug]
Disabled=1

[MeasureLocationLatitude]
Group=Measures
Measure=WebParser
URL=[MeasureLocation]
StringIndex=1

[MeasureLocationLongitude]
Group=Measures
Measure=WebParser
URL=[MeasureLocation]
StringIndex=2

[MeasureLocationName]
Group=Measures
Measure=WebParser
URL=[MeasureLocation]
StringIndex=3

[MeasureUpdateCoordinates]
Measure=Plugin
Plugin=ActionTimer
ActionList=EnableGetLocation | Wait 500 | UpdateLocation Wait 1500 | SetAddress | SetLatitude | SetLongitude | UpdateLog
EnableGetLocation=[!EnableMeasure MeasureLocation]
UpdateLocation=[!UpdateMeasure MeasureLocation]
SetAddress=[!WriteKeyValue Variables Address "[&MeasureLocationName]" "#@#Variables.inc"][!UpdateMeter MeterAddressName][!Redraw][!Log "Address update finished." Debug]
SetLatitude=[!WriteKeyValue Variables LocationLat "[&MeasureLocationLatitude]" "#@#Variables.inc"][!UpdateMeter MeterLatCode][!Redraw][!Log "Latitude update finished." Debug]
SetLongitude=[!WriteKeyValue Variables LocationLong "[&MeasureLocationLongitude]" "#@#Variables.inc"][!UpdateMeter MeterLongCode][!Redraw][!Log "Longitude update finished." Debug]
UpdateLog=[!Log "Address, lat and lon updates finished." Debug]

;-------------------------------------------------------------
;-------------------------------------------------------------


[MeterAddressName]
Meter=String
StringAlign=Center
FontFace=Segoe UI Light
FontColor=#SettingsTextColor1#
FontSize=12
X=516
Y=0r
W=400
Text=#Address#
ClipString=1
SolidColor=#SettingsTextColor2#,80
AntiAlias=1
ToolTipText=Type your real address and press the "Enter" key to Apply changes.
LeftMouseUpAction=[!PluginBang "MeterAddressInput ExecuteBatch 1"][!PluginBang "MeterAddressInput ExecuteBatch 2"]

;-------------------------------------------------------------
; This is the inputtext Plugin
;-------------------------------------------------------------


[MeterAddressInput]
Measure=Plugin
Plugin=InputText.dll
StringAlign=Center
FontFace=Segoe UI Light
FontSize=12
X=320
Y=130
W=800
H=56
AntiAlias=1
FocusDismiss=1
Command1=[!WriteKeyValue Variables Address "$UserInput$" "#@#Variables.inc"][!UpdateMeasure MeasureUpdateCoordinates][!Log "Updating variables." Debug]
DefaultValue="#Address#"
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Doing several things once text changes in InputText box

Post by balala »

There are more mistakes in the posted code:
  • Is not a good idea to not update the skin using WebParser measures, by setting the Update to -1. The default Update=1000 is a much better approach. Recommend it.
  • DynamicVariables=1 can't be used on the [Rainmeter] section. Remove it.
  • The Author option blongs now to the [Metadata] section. Move it.
  • The [Variables] section name, before the DisplayName=Test variable, is missing. Add it.
  • Although you're using variables placed into the Variables.inc file, this file is not included. Add such an option to the end of the [Variables] section, through a @Include=#@#Variables.inc option. Remove the Address variable, if it is included into the Variabels.inc file.
  • The [MeasureUpdateCoordinates] ActionTimer plugin measure is not needed. I'd remove it and would add the bangs of its options into the FinsishAction option of the [MeasureLocation] measure.
  • The !PluginBang bang is deprecated and should be used !CommandMeasure instead.
With all these, the code should look like:

Code: Select all

[Rainmeter]
Update=1000
;DynamicVariables=1

[Metadata]
Author=Zudzug

[Variables]
DisplayName=Test
;Address=louvre, paris, france
LocationLat=48.8611473
LocationLong=2.33802768704666
lang=en
SettingsTextColor1=0,0,0
SettingsTextColor2=255,255,255
AddressURL=https://nominatim.openstreetmap.org/search/#Address#?format=json&limit=1&accept-language=#lang#
;https://nominatim.openstreetmap.org/search/louvre,paris,france?format=json&limit=1&accept-language=en
@Include=#@#Variables.inc

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureLocation]
Measure=WebParser
URL=#AddressURL#
RegExp=(?siU).*"lat":"(.*)","lon":"(.*)","display_name":"(.*)".*
FinishAction=[!Log "Address fetch finished."][!EnableMeasure MeasureLocation][!UpdateMeasure MeasureLocation][!WriteKeyValue Variables Address "[MeasureLocationName]"][!WriteKeyValue Variables LocationLat "[MeasureLocationLatitude]"][!WriteKeyValue Variables LocationLong "[MeasureLocationLongitude]"]

[MeasureLocationLatitude]
Group=Measures
Measure=WebParser
URL=[MeasureLocation]
StringIndex=1

[MeasureLocationLongitude]
Group=Measures
Measure=WebParser
URL=[MeasureLocation]
StringIndex=2

[MeasureLocationName]
Group=Measures
Measure=WebParser
URL=[MeasureLocation]
StringIndex=3

;[MeasureUpdateCoordinates]
;Measure=Plugin
;Plugin=ActionTimer
;ActionList=EnableGetLocation | Wait 500 | UpdateLocation Wait 1500 | SetAddress | SetLatitude | SetLongitude | UpdateLog
;EnableGetLocation=[!EnableMeasure MeasureLocation]
;UpdateLocation=[!UpdateMeasure MeasureLocation]
;SetAddress=[!WriteKeyValue Variables Address "[&MeasureLocationName]"][!UpdateMeter MeterAddressName][!Redraw][!Log "Address update finished." Debug]
;SetLatitude=[!WriteKeyValue Variables LocationLat "[&MeasureLocationLatitude]"][!UpdateMeter MeterLatCode][!Redraw][!Log "Latitude update finished." Debug]
;SetLongitude=[!WriteKeyValue Variables LocationLong "[&MeasureLocationLongitude]"][!UpdateMeter MeterLongCode][!Redraw][!Log "Longitude update finished." Debug]
;UpdateLog=[!Log "Address, lat and lon updates finished." Debug]

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterAddressName]
Meter=String
StringAlign=Center
FontFace=Segoe UI Light
FontColor=#SettingsTextColor1#
FontSize=12
X=516
Y=0r
W=400
Text=#Address#
ClipString=1
SolidColor=#SettingsTextColor2#,80
AntiAlias=1
ToolTipText=Type your real address and press the "Enter" key to Apply changes.
LeftMouseUpAction=[!CommandMeasure "MeterAddressInput" "ExecuteBatch 1"][!CommandMeasure "MeterAddressInput" "ExecuteBatch 2"]

;-------------------------------------------------------------
; This is the inputtext Plugin
;-------------------------------------------------------------

[MeterAddressInput]
Measure=Plugin
Plugin=InputText.dll
StringAlign=Center
FontFace=Segoe UI Light
FontSize=12
X=320
Y=130
W=800
H=56
AntiAlias=1
FocusDismiss=1
Command1=[!WriteKeyValue Variables Address "$UserInput$"][!UpdateMeasure MeasureUpdateCoordinates][!Log "Updating variables."][!EnableMeasure "MeasureLocation"][!CommandMeasure "MeasureLocation" "Update"]
DefaultValue="#Address#"
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Doing several things once text changes in InputText box

Post by eclectic-tech »

zudzug wrote: January 24th, 2020, 5:16 am Good Morning!

I am trying to do this with an InputText box:
1- Update a $variable$ (works as intended).
2- Update a Webparser and its substrings.
3- Update the same variable again, with more detailed info this time, confirming the webparser did its job.
4- Update the meters associated once this is all done.

I am somehow stuck on step 1. The debug info says the ActionTimer gets called by the InputText box, but I don't see any updates going through.
Made a few changes to balala's code syntax corrections.

I replaced URL=#Address# in [MeasureLocation] with the actual web address value
I changed that measure to ForecReload and use dynamic variables [#Address] for the URL
Un-commented the Action Timer code, corrected the syntax; missing a few |, combined some actions, and added dynamic variables
Changed the text of the address display to show the value of the location measure rather than the address variable and added dynamic variables
Changed the Command1 of user input and added OnChangeAction

Now when you input an address, zip code, city name, etc. ... that info is sent to the webparser measure, after it resolves, it updates the variables and meters. Now you are ready for a new search.

I think this is what you requested. You did not include the lat/lon meters, but they should update as well.

Here's working code

Code: Select all

[Rainmeter]
Update=1000
;DynamicVariables=1

[Metadata]
Author=Zudzug

[Variables]
;@Include=#@#Variables.inc
Address=Jersey City, Hudson County, New Jersey, United States of America
DisplayName=Test
;Address=louvre, paris, france
LocationLat=40.7281575
LocationLong=-74.0776417
lang=en
SettingsTextColor1=0,0,0
SettingsTextColor2=255,255,255
;AddressURL=https://nominatim.openstreetmap.org/search/[#Address]?format=json&limit=1&accept-language=#lang#
;https://nominatim.openstreetmap.org/search/louvre,paris,france?format=json&limit=1&accept-language=en

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureLocation]
Measure=WebParser
URL=https://nominatim.openstreetmap.org/search/[#Address]?format=json&limit=1&accept-language=#lang#
RegExp=(?siU).*"lat":"(.*)","lon":"(.*)","display_name":"(.*)".*
FinishAction=[!Log "Address [#Address] fetch finished."][!WriteKeyValue Variables Address "[MeasureLocationName]"][!WriteKeyValue Variables LocationLat "[MeasureLocationLatitude]"][!WriteKeyValue Variables LocationLong "[MeasureLocationLongitude]"][!UpdateMeter *][!Redraw]
ForceReload=1
DynamicVariables=1

[MeasureLocationLatitude]
Group=Measures
Measure=WebParser
URL=[MeasureLocation]
StringIndex=1

[MeasureLocationLongitude]
Group=Measures
Measure=WebParser
URL=[MeasureLocation]
StringIndex=2

[MeasureLocationName]
Group=Measures
Measure=WebParser
URL=[MeasureLocation]
StringIndex=3

[MeasureUpdateCoordinates]
Measure=Plugin
Plugin=ActionTimer
ActionList1=EnableGetLocation | Wait 3000 | SetAddress | Wait 100 | SetLatitude | Wait 100 | SetLongitude | Wait 100 | UpdateLog
EnableGetLocation=[!CommandMeasure MeasureLocation "Update"]
SetAddress=[!WriteKeyValue Variables Address "[&MeasureLocationName]"][!UpdateMeter MeterAddressName][!Redraw][!Log "Address update finished." Debug][!CommandMeasure MeasureLocation "Update"]
SetLatitude=[!WriteKeyValue Variables LocationLat "[&MeasureLocationLatitude]"][!UpdateMeter MeterLatCode][!Redraw][!Log "Latitude update finished." Debug]
SetLongitude=[!WriteKeyValue Variables LocationLong "[&MeasureLocationLongitude]"][!UpdateMeter MeterLongCode][!Redraw][!Log "Longitude update finished." Debug]
UpdateLog=[!Log "Address, lat and lon updates finished." Debug][!UpdateMeter *][!Redraw]
DynamicVariables=1

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterAddressName]
Meter=String
StringAlign=Center
FontFace=Segoe UI Light
FontColor=#SettingsTextColor1#
FontSize=12
X=516
Y=0r
W=400
H=24
Text=[&MeasureLocationName]
ClipString=1
SolidColor=#SettingsTextColor2#,80
Padding=10,10,10,10
AntiAlias=1
ToolTipText=Type your real address and press the "Enter" key to Apply changes.
LeftMouseUpAction=[!CommandMeasure "MeterAddressInput" "ExecuteBatch 1"]
;[!CommandMeasure "MeterAddressInput" "ExecuteBatch 2"]
DynamicVariables=1

;-------------------------------------------------------------
; This is the inputtext Plugin
;-------------------------------------------------------------

[MeterAddressInput]
Measure=Plugin
Plugin=InputText.dll
StringAlign=Center
FontFace=Segoe UI Light
FontSize=13
X=310
Y=10
W=410
H=22
AntiAlias=1
FocusDismiss=1
Command1=[!WriteKeyValue Variables Address "$UserInput$"][!SetVariable Address "[MeterAddressInput]"][!CommandMeasure MeasureUpdateCoordinates "Stop 1"][!CommandMeasure MeasureUpdateCoordinates "Execute 1"][!Log "Updating variables for [MeterAddressInput]."]
DefaultValue=[&MeasureLocationName]
OnChangeAction=[!CommandMeasure MeasureLocation "Update"]
DynamicVariables=1
I may have missed some of the changes I made, but this will take almost any valid 'place info' and turn it into a location with a full name, and the location latitude and longitude.
zudzug
Posts: 7
Joined: January 24th, 2020, 5:01 am

Re: Doing several things once text changes in InputText box

Post by zudzug »

This is all very nice! I've got the code working now. I will post in 1.5 weeks when the skin is done.

Thanks everyone!
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Doing several things once text changes in InputText box

Post by balala »

zudzug wrote: January 24th, 2020, 8:59 pm This is all very nice! I've got the code working now. I will post in 1.5 weeks when the skin is done.
:thumbup:
zudzug
Posts: 7
Joined: January 24th, 2020, 5:01 am

Re: Doing several things once text changes in InputText box

Post by zudzug »

Code: Select all

;-------------------------------------------------------------

[Variables]
@include=#@#Variables.inc

[MeterKeyText]
Meter=String
StringAlign=Left
Text=Enter API Key Here >>
AntiAlias=1

[MeterKeyCode]
Meter=String
StringAlign=Left
X=352r
Y=0r
W=240
Text=#APIKey#
ClipString=1
AntiAlias=1
ToolTipText=Type your "API KEY" and press the "Enter" key to Apply changes.
LeftMouseUpAction=[!CommandMeasure "MeterKeyInput" "ExecuteBatch 1"]
DynamicVariables=1

[MeterKeyInput]
Measure=Plugin
Plugin=InputText.dll
StringAlign=Center
X=960
Y=400r
W=1200
H=112
AntiAlias=1
FocusDismiss=1
Command1=[!WriteKeyValue Variables APIKey "$UserInput$""#@#Variables.inc"][!RainmeterRefreshApp]
DefaultValue=#APIKey#
DynamicVariables=1

;-------------------------------------------------------------

User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Doing several things once text changes in InputText box

Post by balala »

zudzug wrote: June 26th, 2020, 3:25 pm

Code: Select all

;-------------------------------------------------------------

[Variables]
@include=#@#Variables.inc

[MeterKeyText]
Meter=String
StringAlign=Left
Text=Enter API Key Here >>
AntiAlias=1

[MeterKeyCode]
Meter=String
StringAlign=Left
X=352r
Y=0r
W=240
Text=#APIKey#
ClipString=1
AntiAlias=1
ToolTipText=Type your "API KEY" and press the "Enter" key to Apply changes.
LeftMouseUpAction=[!CommandMeasure "MeterKeyInput" "ExecuteBatch 1"]
DynamicVariables=1

[MeterKeyInput]
Measure=Plugin
Plugin=InputText.dll
StringAlign=Center
X=960
Y=400r
W=1200
H=112
AntiAlias=1
FocusDismiss=1
Command1=[!WriteKeyValue Variables APIKey "$UserInput$""#@#Variables.inc"][!RainmeterRefreshApp]
DefaultValue=#APIKey#
DynamicVariables=1

;-------------------------------------------------------------

Do you have any problem with this code, or is their a question?
Note that the !Rainmeter... bang prefix has been deprecated long time ago, same way as the !Execute bang was as well. Remove it from your code, don't use any of them anymore...
zudzug
Posts: 7
Joined: January 24th, 2020, 5:01 am

Re: Doing several things once text changes in InputText box

Post by zudzug »

Hi,

This was not a question, rather than a follow up. I thought it would be nice to post the working code.

Thanks for the pointers.

Regards,
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Doing several things once text changes in InputText box

Post by balala »

zudzug wrote: June 26th, 2020, 7:12 pm This was not a question, rather than a follow up. I thought it would be nice to post the working code.
But at least as far as I can tell, this code has not too much in common with the original code. Has it?
zudzug
Posts: 7
Joined: January 24th, 2020, 5:01 am

Re: Doing several things once text changes in InputText box

Post by zudzug »

My bad, I posted the wrong code snippet from the same file. Look at the last lines of this snippet. The code is doing several things at once with an inputbox.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
ContextTitle=Close Settings Menu
ContextAction=[!DeactivateConfig "#ROOTCONFIG#\Settings" "Settings.ini"][!Update]
ContextTitle2=Disable Scroll
ContextAction2=[!CommandMeasure "MeasureScale" "ONOFF()"][!Refresh]
MouseScrollUpAction=[!CommandMeasure "MeasureScale" "Enlarge()"][!Update]
MouseScrollDownAction=[!CommandMeasure "MeasureScale" "Smaller()"][!Update]
LeftMouseDoubleClickAction=[!ToggleConfig "#ROOTCONFIG#\Settings" "Settings.ini"]

[Metadata]
Name=SettingsPane
Author=Zudzug
Information=Skin to change the parameters of other skins.
Version=2.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
@include=#@#Variables.inc
@include2=#@#Language\Language.inc

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureScale]
Measure=Script
ScriptFile="#@#Scale.lua"
SkinToScale=Settings

[MeasureLocation]
Measure=WebParser
URL=https://nominatim.openstreetmap.org/search/#Address#?format=json&limit=1&accept-language=#lang#
RegExp=(?siU).*"lat":"(.*)","lon":"(.*)","display_name":"(.*)".*
FinishAction=[!Delay 2000][!WriteKeyValue Variables Address "[&MeasureLocationName]""#@#Variables.inc"][!WriteKeyValue Variables LocationLat "[&MeasureLocationLatRounded]""#@#Variables.inc"][!WriteKeyValue Variables LocationLong "[&MeasureLocationLongRounded]""#@#Variables.inc"][!UpdateMeter *][!Refresh][!Log "Address [#Address] fetch finished."]
UpdateRate=-1
Disabled=1
Group=UpdateAddressLatLon

[MeasureLocationLatitude]
Measure=WebParser
URL=[MeasureLocation]
StringIndex=1
Group=UpdateAddressLatLon
Disabled=1
DynamicVariables=1

[MeasureLocationLongitude]
Measure=WebParser
URL=[MeasureLocation]
StringIndex=2
Group=UpdateAddressLatLon
Disabled=1
DynamicVariables=1

[MeasureLocationName]
Measure=WebParser
URL=[MeasureLocation]
StringIndex=3
Group=UpdateAddressLatLon
Disabled=1
DynamicVariables=1

[MeasureLocationLatRounded]
Measure=Calc
Formula=Round([MeasureLocationLatitude],6)
Group=UpdateAddressLatLon
Disabled=1
DynamicVariables=1

[MeasureLocationLongRounded]
Measure=Calc
Formula=Round([MeasureLocationLongitude],6)
Group=UpdateAddressLatLon
Disabled=1
DynamicVariables=1

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterAddressText]
Meter=String
StringAlign=Left
FontColor=#SettingsTextColor2#
FontFace=Segoe UI Light
FontSize=(24*[MeasureScale])
X=(120*[MeasureScale])
Y=(260*[MeasureScale])
Text=#EnterRealLocationText# >>
AntiAlias=1
DynamicVariables=1

[MeterAddressName]
Meter=String
StringAlign=Center
FontFace=Segoe UI Light
FontColor=#SettingsTextColor1#
FontSize=(24*[MeasureScale])
X=(1032*[MeasureScale])
Y=0r
W=(800*[MeasureScale])
Text=#Address#
ClipString=1
SolidColor=#SettingsTextColor2#,80
AntiAlias=1
ToolTipText=Type your real address and press the "Enter" key to Apply changes.
LeftMouseUpAction=[!CommandMeasure "MeterAddressInput" "ExecuteBatch ALL"]
DynamicVariables=1

[MeterAddressInput]
Measure=Plugin
Plugin=InputText.dll
StringAlign=Center
FontFace=Segoe UI Light
FontSize=(24*[MeasureScale])
X=(640*[MeasureScale])
Y=(260*[MeasureScale])
W=(1600*[MeasureScale])
H=(112*[MeasureScale])
AntiAlias=1
FocusDismiss=1
Command1=[!WriteKeyValue Variables Address "$UserInput$""#@#Variables.inc"][!RefreshApp]
Command2=[!Delay 500][!EnableMeasureGroup UpdateAddressLatLon][!UpdateMeasure MeasureLocation][!Log "Updating variables." Debug]
DefaultValue="#Address#"
DynamicVariables=1

;-------------------------------------------------------------
;-------------------------------------------------------------

Post Reply