如何根据PROCESS插件returns的值修改meters或variables?

How to modify meters or variables based on the value that the PROCESS plugin returns?

问题
我正在使用进程插件 (https://docs.rainmeter.net/manual/plugins/process/) 来确定我的系统上有哪些服务 运行。
我当前的输出:

值(on/off)适当改变,但我也想根据值returned改变文本颜色。这是一个在我的系统上运行的示例(arrow.png 在收到度量值时显示红色):

根据我在 Rainmeter 论坛 (https://forum.rainmeter.net/viewtopic.php?t=3335) 上阅读的一篇文章,最好的方法是将字体颜色添加为变量,然后像这样修改它:

[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"

我知道 Process 插件 return 编辑的“-1”和“1”是字符串,需要转换为 int 类型才能被 if 语句识别,但我试过了没有变色。 (包括这段代码)

问题
如何将 Process 插件 ("-1", "1") return 编辑的值 return 作为整数,以便它们可以被识别我的 if 语句?
或者有没有更好的方法来更改 Rainmeter 中的文本颜色?

你可能已经离开了这个问题,但这是我的答案。

你走在正确的轨道上。问题是在 measureSQL 中,您将 -11 替换为 ONOFFAboveValue 无法测量。我删除了 SubstituteAboveValue,并用一个 IfCondition 和两个 MeterStyle 替换了它们。 MeterStyles 取代了对变量的需要,因此您不需要使用 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