In Rainmeter, unlike in some programming languages, to check if the value of a measure is zero, you don't have to use the double equality (==), jut a simple one (=). Accordingly the [CsCpuThrottle] == 0 part of the Formula used into the BarColor option of the [tCpu1] meter should be [CsCpuThrottle] = 0 (see the one single equality sign).First try: This gave the bar a weird color. It's a color that I never declare or wrote anywhere in the script. Which is CYAN.Code:
[Variables]MyAccentColorOpaque=131,192,239MyDarkAccentColorOpaque=200,60,77TheirAccentColor=#MyAccentColorOpaque#,255TheirDarkAccentColor=#MyDarkAccentColorOpaque#,255[CsCpuThrottle]Measure=CalcFormula=1[tCpu1]Meter=BARMeasureName=sCpu1X=#MySectionSpacing#RY=#MyMarginTop#W=#MyBarWidth#H=#MyHeight#BarColor=([CsCpuThrottle] == 0 ? #TheirAccentColor# : #TheirDarkAccentColor#)DynamicVariables=1SolidColor=#MyBarBackground#BarOrientation=Vertical
But even so, the formula can1t work, because (once again) unlike into a programming language, Rainmeter can't work withstrings in formula. Thos formulas (like the one used into the mentioned BarColor option) should be entirely mathematic. However a color code of any type is a string in fact, so a such kind of formula doesn't work in Rainmeter.
the solution is the usage of IfConditions. This way, for instance:
Code:
[CsCpuThrottle]Measure=CalcFormula=1IfCondition=(CsCpuThrottle=0)IfTrueAction=[!SetOption tCpu1 BarColor "#TheirAccentColor#"][!UpdateMeter "tCpu1"][!Redraw]IfFalseAction=[!SetOption tCpu1 BarColor "#TheirDarkAccentColor#"][!UpdateMeter "tCpu1"][!Redraw][tCpu1]...;BarColor=([CsCpuThrottle] == 0 ? #TheirAccentColor# : #TheirDarkAccentColor#);DynamicVariables=1...
Same applies here as well. Strings are not allowed into mathematical formulas in Rainmeter. But one more: even if it wozuld work, you wouldn't see the result, because even if the BarColor would be set to either 0,0,0,0 or 1,1,1,1, these colors are the same. In fact there is no color: 0,0,0,0 is completely transparent black (the last above red colored part sets the transparency of the color, 0 meaning it is completely transparent), while 1,1,1,1 is practically same way transparent (its transparency is 1 from 255, which still means completely invisible). However the BarColor option can't work, due to what have been described above. You get the bar cyan, because not having a valid option for the BarColor, Rainmeter applies the default color, which is 0,128,0, so cyan.Then I tried this:Same result. Weird CYAN color. Not white or black.Code:
[CsCpuThrottle]Measure=CalcFormula=0[tCpu1]Meter=BARMeasureName=sCpu1X=#MySectionSpacing#RY=#MyMarginTop#W=#MyBarWidth#H=#MyHeight#BarColor=([CsCpuThrottle] == 0 ? 0,0,0,0 : 1,1,1,1)DynamicVariables=1SolidColor=#MyBarBackground#BarOrientation=Vertical
No, you didn't try with variables, because neither TheirAccentColor, nor TheirDarkAccentColor is a variable. Variables are #TheirAccentColor# and #TheirDarkAccentColor#, but as described above, you can1t use these in formulas.But I don't want to manually change the value in the script whenever I wanted different accent color.
So I tried with variable:Well this didn't work. It's still white. How about if I added ##Code:
[CsCpuThrottle]Measure=CalcFormula=0[CsCpuColor]Measure=CalcFormula=(CsCpuThrottle = 0 ? TheirAccentColor : TheirDarkAccentColor)[tCpu1]Meter=BARMeasureName=sCpu1X=#MySectionSpacing#RY=#MyMarginTop#W=#MyBarWidth#H=#MyHeight#BarColor=[CsCpuColor]DynamicVariables=1SolidColor=#MyBarBackground#BarOrientation=Vertical
Use the IfCondition option, as described above. Did you get it working?But it doesn't work for tCpu2, and is ugly.
Statistics: Posted by balala — Yesterday, 6:40 pm