It is currently October 9th, 2024, 6:17 pm

[SOLVED] Problem with Registry Measure.

Get help with creating, editing & fixing problems with skins
User avatar
Kruggernaut
Posts: 11
Joined: June 14th, 2010, 7:33 pm
Location: Santiago, Chile

[SOLVED] Problem with Registry Measure.

Post by Kruggernaut »

I'm working with a registry value displayed on a String Meter. When the key value changes, the String meter changes.
When the key is deleted, the String meter shows "Deleted". But ... how do I know a key doesn't exists?

The String meter ALWAYS show what's inside the key. And I notice when the key is deleted, it display 0 (zero)

So, I wrote this:

Code: Select all

[MeasureTitle]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\MediaPlayer\CurrentMetadata
RegValue=Title
IfEqualValue=0
IfEqualAction=!Execute [!RainmeterHideMeter MeterTitle][!RainmeterShowMeter MeterKeyDeleted][!RainmeterRedraw]
What this code actually does, it's hide the MeterTitle and show the meter KeyDeleted DISREGARD the condition given in IfEqualValue. In other words, it just execute the bangs every time I refresh the code, ignoring if the value is zero or not.

Perhaps IfEqualValue doesn't work as I'm thinking?
Please help.

Sorry about the bad english.
Greetings from Chile. :)
Last edited by Kruggernaut on June 19th, 2010, 7:39 am, edited 1 time in total.
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Problem with Registry Measure.

Post by JpsCrazy »

I'm having the SAME problem, just not with a registry value.
For some reason, IfEqualValue=0 isn't working as it should...

As far as I know, you did nothing wrong. And indeed, that is how it should work.

In case it gets resolved on my post first: http://rainmeter.net/forum/viewtopic.php?f=5&t=4397


What's happened so far:
-IfEqualValue=0 broke.
-Simplified code - didn't work
-Did a clean reinstall of Rainmeter - didn't work
-Tried removing the 'IfEqual' portion of the calc, and using the calc as a string value. THAT works.
-Tried changing 'IfEqualValue' to anything but 0 and it worked as it should.

...but we need 0 for this to work how we want it. We'll see where this goes.
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Problem with Registry Measure.

Post by Chewtoy »

You could do a workaround with an if-statement.

Code: Select all

[MeasureTitle]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\MediaPlayer\CurrentMetadata
RegValue=Title

[MCalc]
Measure=Calc
Formula=(Measuretitle<1)?1:0
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterHideMeter MeterTitle][!RainmeterShowMeter MeterKeyDeleted][!RainmeterRedraw]
Simply what that does is checking if [MeasureTitle] is smaller than 1. If it is, it prints 1 and then have the IfEqualValue act based on that. If the [MeasureTitle] is larger than 1, it will spit out 0 and it won't do squat. I think that's valid if [MeasureTitle] is not a number as well.
I don't think, therefore I'm not.
User avatar
Kruggernaut
Posts: 11
Joined: June 14th, 2010, 7:33 pm
Location: Santiago, Chile

Re: Problem with Registry Measure.

Post by Kruggernaut »

JpsCrazy wrote:I'm having the SAME problem, just not with a registry value.
For some reason, IfEqualValue=0 isn't working as it should...

As far as I know, you did nothing wrong. And indeed, that is how it should work.

In case it gets resolved on my post first: http://rainmeter.net/forum/viewtopic.php?f=5&t=4397


What's happened so far:
-IfEqualValue=0 broke.
-Simplified code - didn't work
-Did a clean reinstall of Rainmeter - didn't work
-Tried removing the 'IfEqual' portion of the calc, and using the calc as a string value. THAT works.
-Tried changing 'IfEqualValue' to anything but 0 and it worked as it should.

...but we need 0 for this to work how we want it. We'll see where this goes.
I readed how you manage to solve this problem, but didn't work for me.
I think the diference here is that you always work with numbers. My key value is a string, but 0 when deleted.

Chewtoy wrote:You could do a workaround with an if-statement.

Code: Select all

[MeasureTitle]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\MediaPlayer\CurrentMetadata
RegValue=Title

[MCalc]
Measure=Calc
Formula=(Measuretitle<1)?1:0
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterHideMeter MeterTitle][!RainmeterShowMeter MeterKeyDeleted][!RainmeterRedraw]
Simply what that does is checking if [MeasureTitle] is smaller than 1. If it is, it prints 1 and then have the IfEqualValue act based on that. If the [MeasureTitle] is larger than 1, it will spit out 0 and it won't do squat. I think that's valid if [MeasureTitle] is not a number as well.
Tried that, didn't work either. It asume it's always zero.
And makes sense. Because:

When key deleted.
1.- Key deleted = 0
2.- 0 is below 1? = Yes
3.- Rainmeter: "Ok, I will execute the bangs".

When key has a value.
1.- Key value = A string containing the name of a song. "November rain"
2.- "November rain" is below 1? = ¿¿??
3.- Rainmeter: "WTF? LOL, I will return zero AND execute the bangs just to annoy you".

It seems there is no solution to me.

[EDIT] It's confirmed: When the value is a string, it will become zero automatically. So, the if statements will always asume the value is zero. I need to find another way to achieve my goal, then.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Problem with Registry Measure.

Post by smurfier »

The real problem here is that strings cannot be used in calc measures. They will evaluate to 0.

Code: Select all

[MeasureTitle]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\MediaPlayer\CurrentMetadata
RegValue=Title
Substitute="0":"-1"

[msTry]
Measure=Calc
Formula=MeasureTitle
IfEqualValue=-1
IfEqualAction=!Execute [!RainmeterHideMeter MeterTitle][!RainmeterShowMeter MeterKeyDeleted][!RainmeterRedraw]
Now, if the measure is a string (which will evaluate to 0) nothing happens. The substitute turned the 0 from your original measure into -1 which will make the bangs fire.

Hope this works for you.
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
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Problem with Registry Measure.

Post by JpsCrazy »

You could try something along the lines of this: (Maybe?)

[MeterString1]
Meter=String
Text=Blah, bleh, bloo
X=26
Y=78

[MeterString2]
Meter=String
Text=[MeterString1]
Hidden=1
Substitute="Blah":"0","bleh":"1","bloo":2,",":""
DynamicVariables=1

And use the 2nd one for values, the first one to display the data, if you wish.

Edit: Nevermind, you probably won't know the text that the registry will give you so the substitute won't work.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Problem with Registry Measure.

Post by smurfier »

JpsCrazy wrote:You could try something along the lines of this: (Maybe?)

[MeterString1]
Meter=String
Text=Blah, bleh, bloo
X=26
Y=78

[MeterString2]
Meter=String
Text=[MeterString1]
Hidden=1
Substitute="Blah":"0","bleh":"1","bloo":2,",":""
DynamicVariables=1

And use the 2nd one for values, the first one to display the data, if you wish.

Edit: Nevermind, you probably won't know the text that the registry will give you so the substitute won't work.
Substitutes do not work in meters, only measures.
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
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Problem with Registry Measure.

Post by JpsCrazy »

smurfier wrote:Substitutes do not work in meters, only measures.
Well, that makes me even more wrong. :P
User avatar
Kruggernaut
Posts: 11
Joined: June 14th, 2010, 7:33 pm
Location: Santiago, Chile

Re: Problem with Registry Measure.

Post by Kruggernaut »

smurfier wrote:

Code: Select all

[MeasureTitle]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\MediaPlayer\CurrentMetadata
RegValue=Title
Substitute="0":"-1"

[msTry]
Measure=Calc
Formula=MeasureTitle
IfEqualValue=-1
IfEqualAction=!Execute [!RainmeterHideMeter MeterTitle][!RainmeterShowMeter MeterKeyDeleted][!RainmeterRedraw]
Hope this works for you.
Have you tried that code? It doesn't work for me. It only works if I change "IfEqualValue=-1" to "IfEqualValue=0". (Just that line)

There are three options:
1.- If the code works for you, then I have something wrong in my code.
2.- A string containing a number cannot be parsed.
3.- A deleted registry key returns something like "null", or something ... But it gets represented by zero when displayed on a string meter. That could be the reason behind the Substitute failure.

By the way, I already thougt about using substitute before ... but what if the song name contains a 0? I have a lot of songs who have zeros on the name. The output for songs like "Atv 2009" will look like "Atv 2-1-19"

Thanks anyway.
I'm running out of ideas ...
User avatar
Kruggernaut
Posts: 11
Joined: June 14th, 2010, 7:33 pm
Location: Santiago, Chile

Re: Problem with Registry Measure.

Post by Kruggernaut »

smurfier wrote:

Code: Select all

[MeasureTitle]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\MediaPlayer\CurrentMetadata
RegValue=Title
Substitute="0":"-1"

[msTry]
Measure=Calc
Formula=MeasureTitle
IfEqualValue=-1
IfEqualAction=!Execute [!RainmeterHideMeter MeterTitle][!RainmeterShowMeter MeterKeyDeleted][!RainmeterRedraw]
Ooooo now I see the problem here.
Lets try ...

Code: Select all

[msTry]
Measure=Calc
Formula = [ MeasureTitle ]
IfEqualValue=-1
IfEqualAction=!Execute [!RainmeterHideMeter MeterTitle][!RainmeterShowMeter MeterKeyDeleted][!RainmeterRedraw]
DynamicVariables = 1
Works like a charm. Thanks to all.