It is currently March 28th, 2024, 4:55 pm

IfCondition, change value color

Get help with installing and using Rainmeter.
Post Reply
ycodryn
Posts: 4
Joined: August 19th, 2017, 8:56 pm

IfCondition, change value color

Post by ycodryn »

Hello. I have this plugin for HWinfo and Rainmeter (some part of it):

Code: Select all

[Variables]
HWiNFOColor1=0, 255, 0, 255
HWiNFOColor2=255, 0, 0, 255
HWiNFOColor3=0, 0, 255, 255
HWiNFOColor4=255, 255, 255, 255
@Include=#@#\HWiNFO.inc

[HWiNFOTextStyle]
FontColor=255, 255, 255, 255
FontFace=Tahoma
FontSize=8
AntiAlias=1

; ------------------------------ GPUPerformance Limit - Utilization ------------------------------
[HWiNFOGPU0LimitU]
Measure=Plugin
Plugin=HWiNFO.dll
HWiNFOSensorId=0xe0002000
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x800000e
HWiNFOType=CurrentValue

[MeterHWiNFOGPU0LimitULabel]
Meter=String
X=0
Y=-2R
Text="Performance Limit - Utilization" 
MeterStyle=HWiNFOTextStyle

[MeterHWiNFOGPU0LimitUValue]
Meter=String
MeasureName=HWiNFOGPU0LimitU
X=1R
Y=0r
Text="%1"
NumOfDecimals=0
MeterStyle=HWiNFOTextStyle
FontColor=#HWiNFOColor1#
What I`m trying to do is to use IfCondition to change color depending of CurrentValue (on/off): IfEqualValue=On (or IfMatch=On?), change text color to green or IfEqualValue=Off, change color to red but I`m not so successful doing it. Anyone can help?
Last edited by fonpaolo on August 20th, 2017, 11:41 am, edited 1 time in total.
Reason: Please use the [code] tags to display your code
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: IfCondition, change value color

Post by mak_kawa »

I am not sure about "GPULimitU". HWiNFO returns string values ("On" and "Off") with this? If so, following code would work.

Code: Select all

[HWiNFOGPU0LimitU]
Measure=Plugin
Plugin=HWiNFO.dll
HWiNFOSensorId=0xe0002000
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x800000e
HWiNFOType=CurrentValue
IfMatch=On
IfMatchAction=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor 0,255,0,255]
IfNotMatchAction=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor 255,0,0,255]
or...

Code: Select all

[HWiNFOGPU0LimitU]
Measure=Plugin
Plugin=HWiNFO.dll
HWiNFOSensorId=0xe0002000
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x800000e
HWiNFOType=CurrentValue
IfMatch=On
IfMatchAction=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor 0,255,0,255]
IfMatch2=Off
IfMatchAction2=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor 255,0,0,255]
ycodryn
Posts: 4
Joined: August 19th, 2017, 8:56 pm

Re: IfCondition, change value color

Post by ycodryn »

Hello. Thank you for reply. Yes, HWiNFO returns On or Off values in main window but in Rainmeter it returns 0 (Off) or 16 (On) so I`m trying to use a custom string character that changes color only.
edit: text is not changing color :(
Last edited by ycodryn on August 20th, 2017, 8:12 am, edited 1 time in total.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: IfCondition, change value color

Post by mak_kawa »

Sorry, I didn't try actually the code and confirm the HWiNFO GPU situation.

But probably, HWiNFO returns numeric values and its main window interprets them to display "On" and "Off" expression. So, you can use IfBelow/AboveValue. To clarify, returned values are of two kinds, 0 or 16? If so, following code would work, I think.

Code: Select all

[HWiNFOGPU0LimitU]
Measure=Plugin
Plugin=HWiNFO.dll
HWiNFOSensorId=0xe0002000
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x800000e
HWiNFOType=CurrentValue
IfAboveValue=1
IfAboveAction=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor 0,255,0,255]
IfBelowValue=1
IfBelowAction=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor 255,0,0,255]
ycodryn
Posts: 4
Joined: August 19th, 2017, 8:56 pm

Re: IfCondition, change value color

Post by ycodryn »

Yes, there are 2 types of returned values: 0 for Off and 16 for On. I will try your code, yesterday when I tried IfBelow/AboveValue didn`t worked.

edit: thank you so much for help, is working. I`m still new to Rainmeter :P
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfCondition, change value color

Post by balala »

Just a side note: lately instead of IfActions (IfAboveValue / IfAboveAction, IfBelowValue / IfBelowAction, respectively IfEqualValue / IfEqualAction), a better habit is to use the IfConditions:

Code: Select all

[HWiNFOGPU0LimitU]
...
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor "255,0,0,255"][!UpdateMeter "MeterHWiNFOGPU0LimitUValue"][!Redraw]
IfFalseAction=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor "0,255,0,255"][!UpdateMeter "MeterHWiNFOGPU0LimitUValue"][!Redraw]
I don't use the HWiNFO plugin so I can1t check, but I'd say the IfMatch still could work, but maybe a suplimentar String measure should be used (and probably, especially if the IfConditions or the IfActions are working, doesn't worth):

Code: Select all

[HWiNFOGPU0LimitUString]
Measure=String
String=[HWiNFOGPU0LimitU]
DynamicVariables=1
IfMatch=On
IfMatchAction=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor "0,255,0,255"][!UpdateMeter "MeterHWiNFOGPU0LimitUValue"][!Redraw]
IfNotMatchAction=[!SetOption MeterHWiNFOGPU0LimitUValue FontColor "255,0,0,255"][!UpdateMeter "MeterHWiNFOGPU0LimitUValue"][!Redraw]
Note the quotations, added around the color codes. Although these color codes are composed by numbers, they are strings and as such the quotaton marks should be used: https://forum.rainmeter.net/viewtopic.php?p=129570#p129570
Also note that I added some bangs to update the appropriate meter.
ycodryn
Posts: 4
Joined: August 19th, 2017, 8:56 pm

Re: IfCondition, change value color

Post by ycodryn »

Hey Balala, tried your version and is not working. IfAboveValue will do the job.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfCondition, change value color

Post by balala »

ycodryn wrote:Hey Balala, tried your version and is not working. IfAboveValue will do the job.
Not to stress you, but the IfConditions still should work. As I said, I can't try your code, because I don't use the HWiNFO plugin, but maybe you should try to replace the posted IfCondition with the following one: IfCondition=([HWiNFOGPU0LimitU]=0). If you want to try this, don't forget to add to the same [HWiNFOGPU0LimitU] measure, the DynamicVariables=1 option, because without this option, the new IfCondition won't work, for sure.
Post Reply