It is currently February 22nd, 2019, 3:24 pm
Our most popular Tips and Tricks from the Rainmeter Team and others
-
jsmorley
- Developer
- Posts: 18879
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
jsmorley » July 20th, 2013, 3:07 pm
These are some nice examples from user
Smurfier, that show how you can use !SetVariable to toggle and otherwise control variables.
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
[Variables]
State=0
a=0
b=3
c=27
d=27
e=5
f=0
g=10
[MeterToggleState]
;Toggle variable "State" between 0 and 1
Meter=String
FontSize=13
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Var State=#State#
DynamicVariables=1
LeftMouseUpAction=[!SetVariable State (1-#State#)][!UpdateMeter *][!Redraw]
[MeterToggleNumberZero]
;Toggle a number "a" between "b" and "0"
Meter=String
Y=10R
FontSize=13
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Var a=#a# Var b=#b#
DynamicVariables=1
LeftMouseUpAction=[!SetVariable a (#b#-#a#)][!UpdateMeter *][!Redraw]
[MeterToggleTwoNumbers]
;Toggle a number "c" between two numbers "d" and "e"
Meter=String
Y=5R
FontSize=13
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Var c=#c# Var d=#d# Var e=#e#
DynamicVariables=1
LeftMouseUpAction=[!SetVariable c (#d#+#e#-#c#)][!UpdateMeter *][!Redraw]
[MeterIncrementNumber]
;Increment a number "f" by one, to a maximum of "g", then start over
Meter=String
Y=5R
FontSize=13
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Var f=#f# Var g=#g#
DynamicVariables=1
LeftMouseUpAction=[!SetVariable f (#f#%#g#+1)][!UpdateMeter *][!Redraw]
-
jsmorley
- Developer
- Posts: 18879
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
jsmorley » January 2nd, 2019, 4:20 pm
Toggle the "visibility" of a meter.
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
White=255,255,255
MyAlpha=255
[MeterTest]
Meter=Image
W=100
H=100
SolidColor=#White#,255
DynamicVariables=1
LeftMouseUpAction=[!SetVariable MyAlpha "(1+255-#MyAlpha#)"][!SetOption #CURRENTSECTION# SolidColor "#White#,#*MyAlpha*#"][!UpdateMeter #CURRENTSECTION#][!Redraw]
[MeterTest2]
Meter=Image
X=5R
W=100
H=100
SolidColor=#White#,255
DynamicVariables=1
LeftMouseUpAction=[!SetVariable MyAlpha "(1+255-#MyAlpha#)"][!SetOption #CURRENTSECTION# SolidColor "#White#,#*MyAlpha*#"][!UpdateMeter #CURRENTSECTION#][!Redraw]
The key to this is "escaping" the value for #MyAlpha# as
#*MyAlpha*# that you use with !SetOption in the bang, so that you explicitly set the alpha to either 1 or 255, rather than relying on the variable. That will make it so multiple meters can share the variable, without them all changing at once.