PROBLEM
I am using the Process plugin (https://docs.rainmeter.net/manual/plugins/process/) to determine what services are running on my system.
My current output:
The values (on/off) change appropriately, but I also want to change the text color based on the value returned. Here's an example that is working on my system (arrow.png has red tint whenever measure values are received):
According to an article that I read on the Rainmeter forums (https://forum.rainmeter.net/viewtopic.php?t=3335), the best approach was to add the font color as a variable and then modify it like so:
[Variables]
indicatorText=255,255,255,100
;___SQL SERVER___
[measureSQL]
Measure=Plugin
Plugin=Process.dll
ProcessName=sqlservr.exe
StringIndex=1
Substitute="-1":"OFF","1":"ON"
[measureSQLindicator]
Measure=Calc
Formula=[measureSQL]
;should change text color to green
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable indicatorText 51,255,0
[styleTextRight]
StringCase=None
stringalign=Right
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#indicatorText#
;___SQL___
[meterSQL]
Meter=String
MeasureName=measureSQL
MeterStyle=styleTextLeft
X=15
Y=40
W=97
H=60
Text="SQL Server"
[meterSQLValue]
Meter=String
MeasureName=measureSQL
MeterStyle=styleTextRight
X=195
Y=40
W=97
H=60
Text="%1"
I know that the "-1" and "1" returned by the Process plugin are strings and need to be converted to type int in order to be recognized by the if statements, but everything I've tried has not changed the color. (including this code)
QUESTION
How can I make the values returned by the Process plugin ("-1", "1") return as integers so that they can be recognized by my if statements?
Or is there a better way to change text color in Rainmeter?
You've probably moved on from this question, but here's my answer.
You were on the right track. The problem was that in measureSQL
, you were substituting -1
and 1
with ON
and OFF
, which AboveValue
cannot measure. I removed the Substitute
and AboveValue
, and replaced them with an IfCondition
and two MeterStyle
s. The MeterStyle
s replace the need for a variable, so you don't need to use DynamicVariable
s.
[MeasureSQLStatus]
Measure=Plugin
Plugin=Process.dll
ProcessName=sqlservr.exe
[ToggleSQLStatusText]
Measure=Calc
Formula=[measureSQL]
;should change text color to green
IfCondition=MeasureSQLStatus > 0
IfTrueAction=[!SetOption ProcessStatusText MeterStyle styleONText]
IfFalseAction=[!SetOption ProcessStatusText MeterStyle styleOFFText]
[StyleONText]
FontColor=51,255,0,255
Text="ON"
[StyleOFFText]
FontColor=255,255,255,100
Text="OFF"
[ProcessNameText]
Meter=String
MeasureName=measureSQL
MeterStyle=styleTextLeft
X=15
Y=40
W=97
H=60
Text="SQL Server"
[ProcessStatusText]
Meter=String
StringCase=None
stringalign=Right
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
X=195
Y=40
W=97
H=60