It is currently May 21st, 2022, 6:15 pm

Can't change text color using !SetOption

Get help with creating, editing & fixing problems with skins
bambom
Posts: 4
Joined: April 1st, 2013, 12:09 pm

Can't change text color using !SetOption

Post by bambom »

Hi everyone, I started using Rainmeter some days ago and I am still developing my personal skins.
Initially I started with the "normal" CPU, RAM and Network meters and everything was fine.
Then I decided to use HwInfo to obtain all tha values displayed, and everything was still fine.
The I decided to change the color or the shown value depending on the value itself, and here i started to have problems: i usually set the color using a variable (for example #Color1#) at the beginning of the .ini configuration file, so I can change the colors of the skin very quickly.
the problem is, I am not able to change the color of the shown values, using IfAboveValue, IfAboveAction and !SetOption.

Here's a portion of the configuration file:

Code: Select all

[Rainmeter]
Update=250

[Variables]
Font=Neuropolitical Rg
FontSize1=8
FontSize2=6
FontSize3=12

Color1=255, 255, 255, 255
Color2=255, 255, 255, 200
Color3=255, 255, 255, 150
Color4=255, 255, 255, 100
Color5=255, 255, 255, 50
Red=255, 0, 0, 255
Background=0, 0, 0, 1

Width=(#WORKAREAWIDTH# / 4)
Height=(#WORKAREAHEIGHT# / 20)

;//////////////////////////////////////////////

[MeasureAverageCPU]
Measure=Plugin
Plugin=HwInfo.dll
HWiNFOID=1007030
IfAboveValue=5
IfAboveAction=[!SetOption MeterCPUAverageText FontColor #Red#][!UpdateMeter MeterCPUAverageText][!Redraw]
IfBelowValue=4
IfBelowAction=[!SetOption MeterCPUAverageText FontColor #Color1#][!UpdateMeter MeterCPUAverageText][!Redraw]

;///////////////////////////////////////////

[MeterCPULine]
Meter=Line
MeasureName=MeasureAverageCPU
X=(#Height# * 4)
Y=(#Height# * 0.3)
W=(#Width# - (#Height# * 4))
H=(#Height# * 0.7)
LineCount=1
LineColor=#Color1#
LineWidth=1
SolidColor=#Background#
Autoscale=1
AntiAlias=1

[MeterCPUAverageText]
Meter=String
MeasureName=MeasureAverageCPU
FontFace=#Font#
FontSize=#FontSize3#
FontColor=#Color1#
X=(#Height# / 4)r
Y=0
AntiAlias=1
Text=%1%
UpdateDivider=4
DynamicVariables=1
With this code everything works fine, except fot the color, wich remains allways white (#Color1#).
As you can see I tried also with "DynamicVariables=1" but it doesn't work.

Any help?

PS: sorry for my english, I am not nativ english speaking
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Can't change text color using !SetOption

Post by smurfier »

If you remove the spaces from your color variables or use quotes in the bang everything should work.

!SetOption "MeterCPUAverageText" "FontColor" "#Red#"
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
bambom
Posts: 4
Joined: April 1st, 2013, 12:09 pm

Re: Can't change text color using !SetOption

Post by bambom »

Works perfectly!!!! :o
Thank you very much :bow: now a new era or rainmeter starts for me :rofl:


Just to understand: why do I have to write the bang like

Code: Select all

!SetOption "SomeMeter" "ThingToBeChanged" "Variable"
and not without the quotes?
User avatar
jsmorley
Developer
Posts: 22519
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can't change text color using !SetOption

Post by jsmorley »

bambom wrote:Works perfectly!!!! :o
Thank you very much :bow: now a new era or rainmeter starts for me :rofl:


Just to understand: why do I have to write the bang like

Code: Select all

!SetOption "SomeMeter" "ThingToBeChanged" "Variable"
and not without the quotes?
You need quotes around elements of a bang if they contain spaces. You need square brackets around the entire bang if you have more than one bang on a given "action".
bambom
Posts: 4
Joined: April 1st, 2013, 12:09 pm

Re: Can't change text color using !SetOption

Post by bambom »

Ok I understand but the elements in my bang don't contain spaces (in their names I mean), or you mean the space between the various options inside the bang?

Would this

Code: Select all

!SetOption SomeMeterThingToBeChangedVariable
be correct? Is it what you mean?
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Can't change text color using !SetOption

Post by smurfier »

The issue was that you were using spaces in your variable. The variable is replaced before the bang is being read/executed. The spaces got in the way of Rainmeter understanding that the whole string was to be used. It took the second part of your color code as the name of the config to send the bang to.

Both of these examples are correct.
[!SetOption MeterCPUAverageText FontColor "255, 255, 255, 255"]
[!SetOption MeterCPUAverageText FontColor 255,255,255,255]
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
jsmorley
Developer
Posts: 22519
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can't change text color using !SetOption

Post by jsmorley »

Right. You will never need quotes around the parts of the bang that will never have spaces in them, but will if some "value" you are using contains spaces.

[Variables]
Color=255, 255, 255, 255

[!SetOption SomeMeter FontColor #Color#]

Will produce an error, as (noted by Smurfier) the bang will see that second "255" after the space as a separate element to the bang, and will assume you mean "config" which is the optional 4th parameter to the !SetOption bang.

If you use:

[!SetOption SomeMeter FontColor "#Color#"]

All will be well.

Or if you use:

[Variables]
Color=255,255,255,255

[!SetOption SomeMeter FontColor #Color#]

That will work as well.