Hi,
The following !WriteKeyValue statements (in different Meters) are not working and I haven't the slightest idea why
LeftMouseUpAction=[!SetVariable AlarmState (Neg(#AlarmState#))][!UpdateMeasure @AlarmState][!WriteKeyValue variables AlarmState #AlarmState# "#@#variables.inc"]
LeftMouseUpAction=[!SetVariable SkinState (Neg(#SkinState#))][!UpdateMeasure @SkinState][!WriteKeyValue variables SkinState #SkinState# "#@#variables.inc"]
LeftMouseUpAction=[!SetVariable ClockState (Neg(#ClockState#))][!WriteKeyValue variables ClockState #ClockState# "#@#variables.inc"][!UpdateMeasure @ClockState]
The log shows the change from 1 to -1 and back to 1 with every click, the measures update accordingly and if the variables.inc file is open in notepad++ it warns me the file has been modified by another program
BUT the value of the variables in the variables file does NOT change.
Please help
Thanks
It is currently April 26th, 2024, 11:07 pm
My !WriteKeyValue Bangs Not Working
-
- Posts: 6
- Joined: August 5th, 2020, 7:28 pm
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: My !WriteKeyValue Bangs Not Working
The new value that you changed #AlarmState# to in an action is not available during the same action. You need to use (Neg(#AlarmState#)) in both places, the !SetVariable and the !WriteKeyValue.xavier wrote: ↑August 24th, 2020, 3:31 pm Hi,
The following !WriteKeyValue statements (in different Meters) are not working and I haven't the slightest idea why
LeftMouseUpAction=[!SetVariable AlarmState (Neg(#AlarmState#))][!UpdateMeasure @AlarmState][!WriteKeyValue variables AlarmState #AlarmState# "#@#variables.inc"]
LeftMouseUpAction=[!SetVariable SkinState (Neg(#SkinState#))][!UpdateMeasure @SkinState][!WriteKeyValue variables SkinState #SkinState# "#@#variables.inc"]
LeftMouseUpAction=[!SetVariable ClockState (Neg(#ClockState#))][!WriteKeyValue variables ClockState #ClockState# "#@#variables.inc"][!UpdateMeasure @ClockState]
The log shows the change from 1 to -1 and back to 1 with every click, the measures update accordingly and if the variables.inc file is open in notepad++ it warns me the file has been modified by another program
BUT the value of the variables in the variables file does NOT change.
Please help
Thanks
This simple skin demonstrates:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
AlarmState=-1
[MeterState]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=#AlarmState#
DynamicVariables=1
;LeftMouseUpAction=[!SetVariable AlarmState "(Neg(#AlarmState#))"][!WriteKeyValue Variables AlarmState "#AlarmState#"]
LeftMouseUpAction=[!SetVariable AlarmState "(Neg(#AlarmState#))"][!WriteKeyValue Variables AlarmState "(Neg(#AlarmState#))"]
-
- Posts: 6
- Joined: August 5th, 2020, 7:28 pm
Re: My !WriteKeyValue Bangs Not Working
Really appreciate taking the time: a million thanks.
It (of course) was the solution.
I went to the documentation to see what I had missed and didn't find anything explicit saying that in a mouse action a !setvariable would not be reflected on a following !writekeyvalue or is it documented somewhere else.
It (of course) was the solution.
I went to the documentation to see what I had missed and didn't find anything explicit saying that in a mouse action a !setvariable would not be reflected on a following !writekeyvalue or is it documented somewhere else.
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: My !WriteKeyValue Bangs Not Working
I'm not sure that is documented as such anywhere. I guess it could be.xavier wrote: ↑August 24th, 2020, 4:15 pm Really appreciate taking the time: a million thanks.
It (of course) was the solution.
I went to the documentation to see what I had missed and didn't find anything explicit saying that in a mouse action a !setvariable would not be reflected on a following !writekeyvalue or is it documented somewhere else.
As I said:
While all values in a [!Bang] are automatically "dynamic", in the sense that you don't need DynamicVariables=1 where you use them, they are dynamic within the context of the "action" that they are on. The entire action string is evaluated when it is read, and all variables are dynamically set in it with the current values, then the [!Bangs] are executed one after the other. Each [!Bang] within the action has already had any #Variables# resolved to the current values before any of them are executed. So one [!Bang] within the action can't impact any other [!Bang] within the same action.
It's not really about !WriteKeyValue as such. Any attempt to use !SetVariable in a [!Bang] in an action won't allow that change to be seen by any other [!Bang] within the same action.
Like this:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
AlarmState1=-1
AlarmState2=-1
[MeterState]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=#AlarmState1# | #AlarmState2#
DynamicVariables=1
LeftMouseUpAction=[!SetVariable AlarmState1 "(Neg(#AlarmState1#))"][!SetVariable AlarmState2 "#AlarmState1#]
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: My !WriteKeyValue Bangs Not Working
Naturally this has some complexities. Don't they always.
This:
Will actually work in spite of what I said earlier, since the !UpdateMeasure will cause the value of [MeasureCalc] to be updated everywhere it is used. Since that !UpdateMeasure is executed before the second !SetVariable that uses the measure, it will in fact get the new updated value. Without the intervening !UpdateMeasure, that will not work.
This:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
AlarmState1=-1
[MeasureCalc]
Measure=Calc
Formula=-1
[MeterState]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=#AlarmState1# | [MeasureCalc]
DynamicVariables=1
LeftMouseUpAction=[!SetOption MeasureCalc Formula "(Neg([MeasureCalc]))"][!UpdateMeasure MeasureCalc][!SetVariable AlarmState1 "[MeasureCalc]"]
-
- Rainmeter Sage
- Posts: 7175
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: My !WriteKeyValue Bangs Not Working
What jsmorley is saying in his last post is basically using a measure instead of a variable, in order for the following bangs to be able to "see" its change in the same option. This works well when you have a limited number of such variables, but it can get a bit extensive when you have more. It's somewhat of a trade off.
Another workaround would be to simply put those bangs in different options (or even different measures or meters) that happen sequantially after one another. The effectiveness of this is dictated by the particularities of the code (e.g. sometimes it can be done without affecting the expected behavior, sometimes not), but when it can be done without any drawback, it's a valid choice.
Another workaround would be to simply put those bangs in different options (or even different measures or meters) that happen sequantially after one another. The effectiveness of this is dictated by the particularities of the code (e.g. sometimes it can be done without affecting the expected behavior, sometimes not), but when it can be done without any drawback, it's a valid choice.