It is currently March 28th, 2024, 2:36 pm

Using a string to control Meters

General topics related to Rainmeter.
Post Reply
Vetsus
Posts: 27
Joined: March 7th, 2017, 5:29 pm

Using a string to control Meters

Post by Vetsus »

is there a way to use a string measure to control meters or metergroups?

i have variables i set, but they are strings vs values(ie 0,1,2) and was wondering if you can use them like a calc measure to control options within meters or meter groups?

here is a sample of some code i was playing with trying to make it work but it does not:

Code: Select all

VizGroup=Layout

[Menu_Calc]
Measure=String
String=#VizGroup#
IfCondition=Menu_Calc = Layout
IfTrueAction=[!SetOption Layout_Button FontColor "#Green#"]
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using a string to control Meters

Post by balala »

Obviously there is. Just have to use the IfMatch. Eg replace the above IfCondition and IfTrueAction options with the following ones:

Code: Select all

IfMatch=Layout
IfMatchAction=[!SetOption Layout_Button FontColor "#Green#"]
You need to do this, because, as you probably saw, the IfConditions work only with numeric values.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using a string to control Meters

Post by jsmorley »

You can't use !IfCondition to test a "string" value. IfCondition can only be used with purely numeric values and formulas.

You want to use !Match instead.

https://docs.rainmeter.net/manual/measures/general-options/ifmatchactions/

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
SomeVar=Red

[MeasureGetColor]
Measure=String
String=#SomeVar#
IfMatch=Red
IfMatchAction=[!SetOption MeterColor Text "It's 'Red'"][!SetOption MeterColor FontColor "252,76,76,255"]
IfNotMatchAction=[!SetOption MeterColor Text "It's 'Green'"][!SetOption MeterColor FontColor "105,255,112,255"][
DynamicVariables=1

[MeterRed]
Meter=String
FontSize=11
FontWeight=400
FontColor=252,76,76,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Set Red
LeftMouseUpAction=[!SetVariable SomeVar "Red"]

[MeterGreen]
Meter=String
X=5R
FontSize=11
FontWeight=400
FontColor=105,255,112,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Set Green
LeftMouseUpAction=[!SetVariable SomeVar "Green"]

[MeterColor]
Meter=String
Y=10R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Edit: Balala beat me... ;-)
Post Reply