It is currently March 28th, 2024, 10:42 am

How to apply [Command=Write Key Value] twice at the same time

Get help with creating, editing & fixing problems with skins
Post Reply
gkmaz9
Posts: 67
Joined: August 26th, 2019, 10:42 am

How to apply [Command=Write Key Value] twice at the same time

Post by gkmaz9 »

Variables.inc

Code: Select all

[Variables]
URL=https://aaa.com/Profile/
URL2=https://vvv.com/Profile/

Code: Select all

[Rainmeter]
Update=1000

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

[Box]
Meter=String
FontFace=Open Sans Bold
W=225
H=20
X=90
Y=43
LeftMouseUpAction=[!CommandMeasure "input" "ExecuteBatch 1"][!RainmeterRedraw]
Hidden=0

[input]
Measure=Plugin
Plugin=InputText
W=225
H=20
X=90
Y=43
InlineSetting=CharacterSpacing | 2 | 2
DefaultValue=input
Command1=[!WriteKeyValue "Variables" "URL" "https://aaa.com/Profile/$UserInput$" "#@#Variables.inc"][!Refresh]
Command2=[!WriteKeyValue "Variables" "URL2" "https://vvv.com/Profile/$UserInput$" "#@#Variables.inc"][!Refresh]
DynamicVariables=1
if i enter text once using InputText,
I hope it is recorded in two values in Variables (1 >url, 2>url2)

However, it is only recorded in one place(url). Any good solutions?
Please give me a good answer.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: How to apply [Command=Write Key Value] twice at the same time

Post by death.crafter »

gkmaz9 wrote: October 6th, 2021, 2:44 pm However, it is only recorded in one place(url). Any good solutions?
Please give me a good answer.

Code: Select all

Command1=[!SetVariable UserInput "$UserInput$"][!WriteKeyValue "Variables" "URL" "https://aaa.com/Profile/[#UserInput]" "#@#Variables.inc"][!WriteKeyValue "Variables" "URL2" "https://vvv.com/Profile/[#UserInput]" "#@#Variables.inc"][!Refresh]
The [#UserInput] syntax is needed as it needs to be resolved dynamically.

I could have used #UserInput#, but then I would have to add DynamicVariables=1 to the measure and an extra UpdateMeasure bang to the command.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to apply [Command=Write Key Value] twice at the same time

Post by balala »

death.crafter wrote: October 6th, 2021, 5:18 pm

Code: Select all

Command1=[!SetVariable UserInput "$UserInput$"][!WriteKeyValue "Variables" "URL" "https://aaa.com/Profile/[#UserInput]" "#@#Variables.inc"][!WriteKeyValue "Variables" "URL2" "https://vvv.com/Profile/[#UserInput]" "#@#Variables.inc"][!Refresh]
The [#UserInput] syntax is needed as it needs to be resolved dynamically.
Not necessary. Yep, this might be an approach, however there is a problem with it, namely that you replaced the two different CommandX options with one single.
To get the code working with two such options, there are a few things to clarify (and fix):
  • The LeftMouseUpAction option of the [Box] meter is executing only Command1, the second one not being included into the ExecuteBatch parameter of the !CommandMeasure bang. Add it: LeftMouseUpAction=[!CommandMeasure "input" "ExecuteBatch 1-2"] (or: LeftMouseUpAction=[!CommandMeasure "input" "ExecuteBatch ALL"]. With the original LeftMouseUpAction=[!CommandMeasure "input" "ExecuteBatch 1 option only Command1 has been executed when hiting Enter (also see that I removed the useless and deprecated [!RainmeterRedraw] bang).
  • Is not a good idea to use multiple $UserInput$ macros strings in a single InputText plugin measure, because such in a case:
    multiple input boxes will be created in sequence.
    Accordingly the second macro should be replaced by the name of the measure itself:

    Code: Select all

    [input]
    ...
    Command1=[!WriteKeyValue "Variables" "URL" "https://aaa.com/Profile/$UserInput$"]
    Command2=[!WriteKeyValue "Variables" "URL2" "https://vvv.com/Profile/[input]"][!Refresh]
  • As you can see above, I removed the [!Refresh] bang from the Command1 option, because if it is there, when executing this command, the existing [!Refresh] bang refreshes the skin (this is its purpose) and you never get executed Command2.
If the two options must be kept (for any reason), the above modifications fix the variables writing.
Post Reply