It is currently March 28th, 2024, 3:09 pm

In "System" Tutorial, CPUPerfect FontColor is broken

Get help with creating, editing & fixing problems with skins
Post Reply
highpec
Posts: 14
Joined: June 17th, 2018, 8:01 am

In "System" Tutorial, CPUPerfect FontColor is broken

Post by highpec »

I'm a complete newbie with Rainmeter but I'm trying to make a custom monitoring script with HWiNFO for the multiple VPS/servers I have in my house.

So I'm following the "System" tutorial here:

https://docs.rainmeter.net/manual/getting-started/basic-tutorials/system/

And nothing I do will change the color of the CPU usage % text. The variable would be forced to stay at LightBlue no matter what I changed it to.

It ends up if you change
[MeterCPUPercent]

to
[MeterCPUPercentLabel]

The font color will not change properly. I have no idea if that's how it's supposed to work, but that's the only way I could get it to change.

Is this the correct way to do this?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: In "System" Tutorial, CPUPerfect FontColor is broken

Post by eclectic-tech »

highpec wrote:I'm a complete newbie with Rainmeter but I'm trying to make a custom monitoring script with HWiNFO for the multiple VPS/servers I have in my house.

So I'm following the "System" tutorial here:

https://docs.rainmeter.net/manual/getting-started/basic-tutorials/system/

And nothing I do will change the color of the CPU usage % text. The variable would be forced to stay at LightBlue no matter what I changed it to.

It ends up if you change
[MeterCPUPercent]

to
[MeterCPUPercentLabel]

The font color will not change properly. I have no idea if that's how it's supposed to work, but that's the only way I could get it to change.

Is this the correct way to do this?
That is how you would normally change the font color, but what you missed is that a conditional control was coded in the [MeasureCPU] that automatically sets the font color option of [MeterCPUPercent] on every update of the skin.

Code: Select all

[MeasureCPU]
Measure=CPU
IfAboveValue=24
IfAboveAction=[!SetOption MeterCPUPercent FontColor #LightRed#][!UpdateMeter *][!Redraw]
IfBelowValue=25
IfBelowAction=[!SetOption MeterCPUPercent FontColor #LightBlue#][!UpdateMeter *][!Redraw]

On every update of the skin, the code above will check the current value and set the FontColor based on the reading.
Your change worked because you changed the section name, so the !SetOption could no longer find [MeterCPUPercent] to set the font color; now it will use whatever value you set.

The better solution would be to remove the condition test from [MeasureCPU]

Code: Select all

[MeasureCPU]
Measure=CPU
or modify it to change to the colors you want. I would suggest using IfCondition, rather than IfAbove/IfBelow if you are going to modify the test.

Code: Select all

[MeasureCPU]
Measure=CPU
IfCondition=(MeasureCPU<25)
IfTrueAction=[!SetOption MeterCPUPercent FontColor #LightBlue#][!UpdateMeter *][!Redraw]
IfCondition2=(MeasureCPU>24)&&(MeasureCPU<75)
IfTrueAction2=[!SetOption MeterCPUPercent FontColor #MediumBlue#][!UpdateMeter *][!Redraw]
IfCondition3=(MeasureCPU>74)
IfTrueAction3=[!SetOption MeterCPUPercent FontColor #LightRed#][!UpdateMeter *][!Redraw]
Using IfCondition allows for more flexibility based on an unlimited number of condition checks.

You will find there are many ways to achieve the same results when coding, what you did worked, but it may not be the best way to go about it. :welcome:
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: In "System" Tutorial, CPUPerfect FontColor is broken

Post by balala »

highpec wrote:I'mSo I'm following the "System" tutorial here:

https://docs.rainmeter.net/manual/getting-started/basic-tutorials/system/

And nothing I do will change the color of the CPU usage % text. The variable would be forced to stay at LightBlue no matter what I changed it to.
EDIT: Sorry, eclectic-tech beat me. Again. As usually...

Removed reply...
highpec
Posts: 14
Joined: June 17th, 2018, 8:01 am

Re: In "System" Tutorial, CPUPerfect FontColor is broken

Post by highpec »

eclectic-tech wrote:That is how you would normally change the font color, but what you missed is that a conditional control was coded in the [MeasureCPU] that automatically sets the font color option of [MeterCPUPercent] on every update of the skin.

Code: Select all

[MeasureCPU]
Measure=CPU
IfAboveValue=24
IfAboveAction=[!SetOption MeterCPUPercent FontColor #LightRed#][!UpdateMeter *][!Redraw]
IfBelowValue=25
IfBelowAction=[!SetOption MeterCPUPercent FontColor #LightBlue#][!UpdateMeter *][!Redraw]

On every update of the skin, the code above will check the current value and set the FontColor based on the reading.
Your change worked because you changed the section name, so the !SetOption could no longer find [MeterCPUPercent] to set the font color; now it will use whatever value you set.

The better solution would be to remove the condition test from [MeasureCPU]

Code: Select all

[MeasureCPU]
Measure=CPU
or modify it to change to the colors you want. I would suggest using IfCondition, rather than IfAbove/IfBelow if you are going to modify the test.

Code: Select all

[MeasureCPU]
Measure=CPU
IfCondition=(MeasureCPU<25)
IfTrueAction=[!SetOption MeterCPUPercent FontColor #LightBlue#][!UpdateMeter *][!Redraw]
IfCondition2=(MeasureCPU>24)&&(MeasureCPU<75)
IfTrueAction2=[!SetOption MeterCPUPercent FontColor #MediumBlue#][!UpdateMeter *][!Redraw]
IfCondition3=(MeasureCPU>74)
IfTrueAction3=[!SetOption MeterCPUPercent FontColor #LightRed#][!UpdateMeter *][!Redraw]
Using IfCondition allows for more flexibility based on an unlimited number of condition checks.

You will find there are many ways to achieve the same results when coding, what you did worked, but it may not be the best way to go about it. :welcome:
Yes, total rookie mistake, I can't believe I completely missed the reference in the re-draw command. Thank you for the prompt response though! I am having a lot of fun with this program. Have almost completed my first monitoring skin... a skin that will be running on a small 15.6" USB monitor connected to a mini-PC that will display all the stats about my servers... and hopefully, my earnings as well (if I can figure out WebParser - the networks offer basic HTTP authentication for downloading XML reports), along with some other things like Bitcoin :). This program is truly amazing. It's like learning a new coding language -- a lot of repetitive stuff, but it's really not that hard to understand once you get going.

One thing that has helped me immensely is this small "Rainmeter-Refresh-Button" from DeviantArt. I made a massive button to press while I design the skin on my other monitor.
Post Reply