It is currently March 29th, 2024, 7:40 am

Check string variables with one Measure.

Get help with creating, editing & fixing problems with skins
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Check string variables with one Measure.

Post by kyriakos876 »

jsmorley wrote:You will have to change the Lua a bit to eliminate checking the alpha value, but sure...
It works without the second lua, I will post the result when I'm done with the skin. Thanks!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Check string variables with one Measure.

Post by jsmorley »

The beauty of this approach of course is that the CheckColor() function can be used anywhere in your skin, and as many times as you need to check different color variables.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Check string variables with one Measure.

Post by jsmorley »

There is no need to ever use numeric values, other than the return number that you are testing for with the IfCondition.

'1' ~= '2' is just as true as 1 ~= 2, and '2' ~= '2' is just as false as 2 ~= 2
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Check string variables with one Measure.

Post by balala »

kyriakos876 wrote:I could get the R,G and B dissected with the plugin, but I thought as they are strings, for example Var1=255,0,0 etc... it should be fine...
I suppose jsmorley will disagree me and the native Rainmeter approach indeed has to use up to eight measures, but here is a solution, with no lua:

Code: Select all

[Variables]
Var1=255,140,121,200
Def1=255,140,121,200

[MeasureRedVar]
Measure=String
String=#Var1#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\1"

[MeasureGreenVar]
Measure=String
String=#Var1#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\2"

[MeasureBlueVar]
Measure=String
String=#Var1#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\3"

[MeasureAlphaVar]
Measure=String
String=#Var1#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\4"

[MeasureRedDef]
Measure=String
String=#Def1#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\1"

[MeasureGreenDef]
Measure=String
String=#Def1#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\2"

[MeasureBlueDef]
Measure=String
String=#Def1#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\3"

[MeasureAlphaDef]
Measure=String
String=#Def1#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\4"

[MeasureCheck]
Measure=Calc
Formula=(( [MeasureRedVar] = [MeasureRedDef] ) + ( [MeasureGreenVar] = [MeasureGreenDef] ) + ( [MeasureBlueVar] = [MeasureBlueDef] ) + ( [MeasureAlphaVar] = [MeasureAlphaDef] ))
IfCondition=(#CURRENTSECTION#=4)
IfTrueAction=[!Log "All match"]
IfFalseAction=[!Log "Not all match"]
DynamicVariables=1
The [MeasureRedVar], [MeasureGreenVar], [MeasureBlueVar] and [MeasureAlphaVar], respectively [MeasureRedDef], [MeasureGreenDef], [MeasureBlueDef], [MeasureAlphaDef] measures are used only to dissect the two color codes into their components. The [MeasureCheck] measure checks if the appropriate color components are matching each other, or not.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Check string variables with one Measure.

Post by jsmorley »

Yike! ;-)

It's not really the requested test is it... He doesn't want "All match" or "Not all match", but rather "None match" or "At least one matches".

"None match" is the trickiest one to get in Rainmeter, particularly when using IfCondition to test as numbers, since 1+2 is the same as 2+1 mathematically, but not in the sense of position.

A second test could be added in the Lua to also return based on "All match" or "Not all match", but he didn't ask for that.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Check string variables with one Measure.

Post by balala »

jsmorley wrote:It's not really the requested test is it... He doesn't want "All match" or "Not all match", but rather "None match" or "At least one matches".
I'm sorry, it seems I misunderstood kyriakos876's request, and you're right.
But this isn't a problem. The [MeasureCheck] measure has to be rewritten a bit. Like:

Code: Select all

[MeasureCheck]
Measure=Calc
Formula=(( [MeasureRedVar] <> [MeasureRedDef] ) + ( [MeasureGreenVar] <> [MeasureGreenDef] ) + ( [MeasureBlueVar] <> [MeasureBlueDef] ) + ( [MeasureAlphaVar] <> [MeasureAlphaDef] ))
IfCondition=(#CURRENTSECTION#=4)
IfTrueAction=[!Log "None match"]
IfFalseAction=[!Log "One or more match"]
DynamicVariables=1
I'm sorry for my inattention.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Check string variables with one Measure.

Post by kyriakos876 »

Ok, I'm done with the skin.
Here goes nothing:

Load the skin, and you will find out it uses a ghetto way to check for "Maximized" windows. Many reported that the translucent taskbar was annoying when a window was maximized but beautiful on desktop or non-maximized.

Now, This draw 4 pixels on each corner of the desktop and checks them to see if all have changed. This would mean some window is maximized.

Now the issues are:

1) The height of the taskbar might be different on some resolutions/ setups.
2) You have to change the color of the 4 meters everytime you change your wallpaper. I, personally will put it to 0,0,3 because it's almost invisible and goes "into" the bezels of my monitor, I don't use 0,0,0 because many fullscreen videos etc, might use 0,0,0 to fill the backgroun, so 0,0,3 is pretty odd to be used somewhere else.
3) I can't find another way than unloading and loading a skin which is pretty slow.

Any ideas?
You do not have the required permissions to view the files attached to this post.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Check string variables with one Measure.

Post by kyriakos876 »

balala wrote:I'm sorry, it seems I misunderstood kyriakos876's request, and you're right.
But this isn't a problem. The [MeasureCheck] measure has to be rewritten a bit. Like:

Code: Select all

[MeasureCheck]
Measure=Calc
Formula=(( [MeasureRedVar] <> [MeasureRedDef] ) + ( [MeasureGreenVar] <> [MeasureGreenDef] ) + ( [MeasureBlueVar] <> [MeasureBlueDef] ) + ( [MeasureAlphaVar] <> [MeasureAlphaDef] ))
IfCondition=(#CURRENTSECTION#=4)
IfTrueAction=[!Log "None match"]
IfFalseAction=[!Log "One or more match"]
DynamicVariables=1
I'm sorry for my inattention.
It's cool, if you want check my last post above, I think you will understand what exactly I wanted to achieve. I think I did it though so I appreciate your ideas.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Check string variables with one Measure.

Post by balala »

kyriakos876 wrote:It's cool, if you want check my last post above, I think you will understand what exactly I wanted to achieve. I think I did it though so I appreciate your ideas.
As usually there are more solutions to the same question. You can use anyone you want. It's your choice.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Check string variables with one Measure.

Post by kyriakos876 »

balala wrote:As usually there are more solutions to the same question. You can use anyone you want. It's your choice.
True that my friend! Solutions are many indeed.