It is currently April 26th, 2024, 3:22 pm

if condition regkey

Get help with creating, editing & fixing problems with skins
dcooman
Posts: 4
Joined: October 18th, 2018, 11:57 am

if condition regkey

Post by dcooman »

I have e problem:

if the regkey Test = ok then text has to be "ok"
if the regkey Test does not exist or 0 then tekst has te be "Nok"

Code: Select all

[Computer_zone]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SYSTEM\Example
RegValue=Test
IfCondition=(computer_zone = ok)
IfTrueAction=[!SetOption computer_text Text "OK"]
IfCondition2=(zenworks_zone = 0)
IfTrueAction2=[!SetOption computer_text Text "NOK"]
Last edited by balala on October 18th, 2018, 12:45 pm, edited 1 time in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: if condition regkey

Post by eclectic-tech »

dcooman wrote: October 18th, 2018, 12:05 pm I have e problem:

if the regkey Test = ok then text has to be "ok"
if the regkey Test does not exist or 0 then tekst has te be "Nok"

Code: Select all

[Computer_zone]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SYSTEM\Example
RegValue=Test
IfCondition=(computer_zone = ok)
IfTrueAction=[!SetOption computer_text Text "OK"]
IfCondition2=(zenworks_zone = 0)
IfTrueAction2=[!SetOption computer_text Text "NOK"]
You do not define "zenworks_zone", so I am not sure what you are testing in IfCondition2 :confused:

IfCondition can only test numeric values. In order to test character matches you need to use IfMatch.

Try this code:

Code: Select all

[Computer_zone]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SYSTEM\Example
RegValue=Test
IfMatch=(?i).*ok.*
IfMatchAction=[!SetOption computer_text Text "OK"]
IfMatch2=^$
IfMatchAction2=[!SetOption computer_text Text "NOK"]
IfCondition=(Computer_zone = 0)
IfTrueAction=[!SetOption computer_text Text "NOK"]

[computer_text]
Meter=String
FontSize=12
FontColor=255,255,255
The IfMatch=(?i).*ok.* will test the current measure string value for the letters "ok" (case insensitive) and set the text value to "OK" if there is a match.

The IfMatch2=^$ will test the current measure string value for an empty string and set the text to "NOK" if the string is empty.

The IfCondition will test the number value of [Computer_zone] and set the text to "NOK" if the value is zero.

Note that IfMatch test the string value of the measure it is in, while the IfCondition can test ANY measure you specify no matter which measure it is coded in.

The code works on my PC, but as noted, I am not sure what 'zenworks_zone" is...
dcooman
Posts: 4
Joined: October 18th, 2018, 11:57 am

Re: if condition regkey

Post by dcooman »

Thank you very much !!
it works (zenworks_zone had to be computer_zone)
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: if condition regkey

Post by eclectic-tech »

Glad to help!