It is currently April 18th, 2024, 10:59 am
Help with !SetVariable
-
- Posts: 16
- Joined: January 31st, 2021, 3:38 pm
Help with !SetVariable
Please tell me why this code does not work. instead of value it writes # mytest #
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Help with !SetVariable
!Bangs are used as the result of some "action", and can't simply be used on their own. In addition, Meters can't have an "action". That must be done in the context of a Measure (or the Rainmeter) section of the skin.
Measures are the components that "measure" or "act". Meters can only "display".
https://docs.rainmeter.net/manual/bangs/
https://docs.rainmeter.net/manual/skins/option-types/#Action
So like this for example:
Now as written this is not particularly useful. The Calc measure I added is only to demonstrate how you use !Bangs in the context of some "action".
Measures are the components that "measure" or "act". Meters can only "display".
https://docs.rainmeter.net/manual/bangs/
https://docs.rainmeter.net/manual/skins/option-types/#Action
So like this for example:
Code: Select all
[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
[Variables]
mytest=1
[MeasureUpdateValue]
Measure=Calc
Formula=#mytest#
DynamicVariables=1
IfCondition=MeasureUpdateValue = 1
IfTrueAction=[!SetVariable mytest "0"]
[MeterMyVar]
Meter=String
Text=Value #mytest#
FontColor=255,255,255,90
DynamicVariables=1
-
- Posts: 16
- Joined: January 31st, 2021, 3:38 pm
Re: Help with !SetVariable
Thank you very much!
-
- Rainmeter Sage
- Posts: 16143
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Help with !SetVariable
Or a meter can have a mouse action. For instance:
Code: Select all
[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
[Variables]
mytest=1
[MeterMyVar]
Meter=String
Text=Value #mytest#
FontColor=255,255,255,90
SolidColor=0,0,0,1
DynamicVariables=1
LeftMouseUpAction=[!SetVariable mytest "0"][!UpdateMeter "MeterMyVar"][!Redraw]
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Help with !SetVariable
Correct...balala wrote: ↑January 31st, 2021, 5:20 pm Or a meter can have a mouse action. For instance:In this case the mytest variable gets the new value (0), when you click the meter (the old value of the variable, 1 in this case).Code: Select all
[Rainmeter] Update=1000 BackgroundMode=2 SolidColor=0,0,0,1 DynamicWindowSize=1 [Variables] mytest=1 [MeterMyVar] Meter=String Text=Value #mytest# FontColor=255,255,255,90 SolidColor=0,0,0,1 DynamicVariables=1 LeftMouseUpAction=[!SetVariable mytest "0"][!UpdateMeter "MeterMyVar"][!Redraw]
-
- Posts: 16
- Joined: January 31st, 2021, 3:38 pm
Re: Help with !SetVariable
I'm probably not the best student, but could you please explain why !SetOption in the commented section works, but
!SetVariable no
!SetVariable no
-
- Rainmeter Sage
- Posts: 16143
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Help with !SetVariable
Because when you set a variable with a !SetVariable bang, you have to set on the dynamic variables onto any measure or meter where you want to use the variable, adding a DynamicVariables=1 option. !SetOption does work even if you don't add the DynamicVariables option, because Rainmeter sets the appropriate measure or meter dynamic for one update cycle, even if you explicitely don't add the option.Xdominanta wrote: ↑February 6th, 2021, 7:05 pm I'm probably not the best student, but could you please explain why !SetOption in the commented section works, but
!SetVariable no
So long story short, add the DynamicVariables=1 option to the [MeterValueCPU] meter if you want to use the dynamically set variable onto it. Don't add it, if you set dynamically an option (through the !SetOption bang).
-
- Posts: 16
- Joined: January 31st, 2021, 3:38 pm
Re: Help with !SetVariable
Thanks!
-
- Rainmeter Sage
- Posts: 16143
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Help with !SetVariable
You're welcome.
-
- Posts: 16
- Joined: January 31st, 2021, 3:38 pm
Re: Help with !SetVariable
Well! Thanks to your help, we managed to decorate my desktop a little. Thank you very much!