Hi guys,
I want to give a feedback about the use of "Registry Measure".
When I use "Measure=Registry", if the content I want to detect is a key or value that does not exist in the registry, Measure will return the number "0" and the string "0". But I cannot use "IfMatch=^0$" to perform related judgment operations, as if it is invalid.
In addition, I also found that if I want to use the Bang "!SetOption" to change "RegKey" in the Registry Measure, if I switch from a key that exists in the registry to a key that does not exist, the value returned by the Measure will not change or become "0". If the value exists in the registry, it can be changed normally.
I am not sure if the situation mentioned above is a problem with the registry itself or a bug in Rainmeter. Hope to get an answer.
Thank you!
It is currently January 22nd, 2021, 4:06 pm
A question about "Registry Measure"
-
- Posts: 32
- Joined: October 21st, 2018, 2:55 am
-
- Rainmeter Sage
- Posts: 12095
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: A question about "Registry Measure"
Try to use IfMatch=0.Lssg97 wrote: ↑November 26th, 2020, 10:41 am When I use "Measure=Registry", if the content I want to detect is a key or value that does not exist in the registry, Measure will return the number "0" and the string "0". But I cannot use "IfMatch=^0$" to perform related judgment operations, as if it is invalid.
I think it does work. See the code of the following Registry measure:Lssg97 wrote: ↑November 26th, 2020, 10:41 am In addition, I also found that if I want to use the Bang "!SetOption" to change "RegKey" in the Registry Measure, if I switch from a key that exists in the registry to a key that does not exist, the value returned by the Measure will not change or become "0". If the value exists in the registry, it can be changed normally.
Code: Select all
[MeasureWindowsVersion]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=Software\Microsoft\Windows NT\CurrentVersion
;RegValue=ProductName
So here is the whole code of the skin I used:
Code: Select all
[Rainmeter]
DynamicWindowSize=1
AccurateText=1
[Variables]
MyVar=1
[MeasureMyVar]
Measure=Calc
Formula=#MyVar#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption MeasureWindowsVersion RegValue "ProducteName"][!UpdateMeasure "MeasureWindowsVersion"]
IfFalseAction=[!SetOption MeasureWindowsVersion RegValue "ProductName"][!UpdateMeasure "MeasureWindowsVersion"]
DynamicVariables=1
[MeasureWindowsVersion]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=Software\Microsoft\Windows NT\CurrentVersion
;RegValue=ProductName
IfMatch=0
IfMatchAction=[!SetOption MeterString FontColor "0,255,0"][!UpdateMeter "MeterString"][!Redraw]
IfNotMatchAction=[!SetOption MeterString FontColor "255,0,0"][!UpdateMeter "MeterString"][!Redraw]
[MeterString]
Meter=STRING
MeasureName=MeasureWindowsVersion
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%1
DynamicVariables=1
LeftMouseUpAction=[!SetVariable MyVar "(1-#MyVar#)"][!UpdateMeasure "MeasureMyVar"]
-
- Posts: 32
- Joined: October 21st, 2018, 2:55 am
Re: A question about "Registry Measure"
Hi balala,
First of all thank you for your answers. The content you showed works perfectly, but it is a little different from what I encountered.
According to the user manual, if not specified "RegValue", the default value is retrieved. Every existing Key in the registry contains a default value, even if no value is set, it is existing in the registry . But if the content I want to retrieve does not have a corresponding Key in the registry, I will encounter the problem I have reported above.
I have modified two lines of content based on your code. You can try the effect of the following skin to understand the problem I encountered.
Code: Select all
[Rainmeter]
DynamicWindowSize=1
AccurateText=1
[Variables]
MyVar=1
[MeasureMyVar]
Measure=Calc
Formula=#MyVar#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption MeasureWindowsVersion RegKey "Software\Microsoft\Windows NT\CurrentVersion"][!UpdateMeasure "MeasureWindowsVersion"]
IfFalseAction=[!SetOption MeasureWindowsVersion RegKey "Software\Microsoft\Windows NT\CurrentVersion2"][!UpdateMeasure "MeasureWindowsVersion"]
DynamicVariables=1
[MeasureWindowsVersion]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=Software\Microsoft\Windows NT\CurrentVersion
RegValue=ProductName
IfMatch=0
IfMatchAction=[!SetOption MeterString FontColor "0,255,0"][!UpdateMeter "MeterString"][!Redraw]
IfNotMatchAction=[!SetOption MeterString FontColor "255,0,0"][!UpdateMeter "MeterString"][!Redraw]
[MeterString]
Meter=STRING
MeasureName=MeasureWindowsVersion
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%1
DynamicVariables=1
LeftMouseUpAction=[!SetVariable MyVar "(1-#MyVar#)"][!UpdateMeasure "MeasureMyVar"]
Last edited by Lssg97 on November 27th, 2020, 4:46 pm, edited 1 time in total.
-
- Rainmeter Sage
- Posts: 12095
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: A question about "Registry Measure"
Yep, right. Unfortunatelly there probably is no solution for your problem, because if you're switching from an existent key to a non-existent, the Registry measure keeps returning the last valid value, so the last existing value. There are more such behaviours of Rainmeter in some circumstances.Lssg97 wrote: ↑November 26th, 2020, 4:03 pm According to the user manual, if not specified "RegValue", the default value is retrieved. Every existing Key in the registry contains a default value, even if no value is set, it is existing in the registry . But if the content I want to retrieve does not have a corresponding Key in the registry, I will encounter the problem I have reported above.
I have modified two lines of content based on your code. You can try the effect of the following skin to understand the problem I encountered.
This definitely isn't exactly the same question, but a similar question arose a while ago. Then brian (who is a developer) explained a few things about how things are working in Rainmeter, something similar should be the explanation here as well.
-
- Posts: 32
- Joined: October 21st, 2018, 2:55 am
Re: A question about "Registry Measure"
Okay, I got it. Maybe the truth is like what Brian said. It looks like Rainmeter treats non-existent registry keys as invalid inputs. I originally thought that Measure could return an empty string for a non-existent registry key, but it would be a pity if not.balala wrote: ↑November 26th, 2020, 4:29 pm This definitely isn't exactly the same question, but a similar question arose a while ago. Then brian (who is a developer) explained a few things about how things are working in Rainmeter, something similar should be the explanation here as well.
Thanks again for your answers.

-
- Rainmeter Sage
- Posts: 12095
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: A question about "Registry Measure"
I'm glad if you got an answer to your question, even if it's not exactly what have you expected.Lssg97 wrote: ↑November 26th, 2020, 5:17 pm Okay, I got it. Maybe the truth is like what Brian said. It looks like Rainmeter treats non-existent registry keys as invalid inputs. I originally thought that Measure could return an empty string for a non-existent registry key, but it would be a pity if not.
Thanks again for your answers.![]()