0

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:
enter image description here

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):
enter image description here

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?

ITSUUUUUH
  • 189
  • 1
  • 3
  • 18
  • Give it a try with a `Dynamic Variable` [link](https://docs.rainmeter.net/manual/variables/#DynamicVariables). String types are generally automatically detected and converted as need be – thatsIch Nov 20 '16 at 08:14

1 Answers1

1

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 MeterStyles. The MeterStyles replace the need for a variable, so you don't need to use DynamicVariables.

[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
  • Thanks for the response! Ill give this a try when I'm back in the office tomorrow. – ITSUUUUUH Sep 18 '17 at 21:48
  • This works perfectly! I found that my main issue in updating the text color was that I was setting a constant in the meter itself and I dont think it was able to update that value effectively. – ITSUUUUUH Sep 19 '17 at 16:21