It is currently April 27th, 2024, 1:47 pm

measure + calc for button name why won't this work

Get help with creating, editing & fixing problems with skins
User avatar
Scolex
Posts: 111
Joined: July 31st, 2010, 8:52 am

measure + calc for button name why won't this work

Post by Scolex »

Here is what I have as well as the display of what a string meter returns so I know the calc is working correctly.

Code: Select all

[MeasureVars]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=file://D:\Documents\Rainmeter\Skins\RmMc\Resources\Variables\UserVariables.inc
RegExp="(?siU)PosBarW=(.*)\n.*PosBarH=(.*)\n"
Debug=1

[MeasurePosBarW]
Measure=Plugin
Plugin=Plugins\Webparser.dll
Url=[MeasureVars]
StringIndex=1
DynamicVariables=1

[MeasurePosBarH]
Measure=Plugin
Plugin=Plugins\Webparser.dll
Url=[MeasureVars]
StringIndex=2
DynamicVariables=1

[Calc4ButW]
Measure=Calc
Formula=MeasurePosBarW/20

[Calc4ButH]
Measure=Calc
Formula=MeasurePosBarH+10

;[Display]*********************************************************************

[b60]
Meter=Button
X=0
Y=0
H=20
W=27
LeftMouseUpAction=!Execute ["#MCxx#" "/MCC 10035, 3600000"]
MouseActionCursor=1
ButtonImage=#CURRENTPATH#Images\[Calc4ButW][Calc4ButH].png
Antialias=1
I have an image named 2720.png and below is an image of what a test string meter returns (the alpha characters and underscore are from "Prefix".
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: measure + calc for button name why won't this work

Post by jsmorley »

Just add DynamicVariables=1 to the Button meter that is using measure results in the ButtonImage= statement, and you should be all set.

This works for me with an image named 500.png in the current path:

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Measure1]
Measure=Calc
Formula=(250 * 2)

[MeterButton]
Meter=Button
ButtonImage=#CURRENTPATH#[Measure1].png
ButtonCommand=!Execute ["http://cnn.com"]
DynamicVariables=1

Few notes:

* You can remove the DynamicVariables=1 statements from the WebParser measures, they don't need them. The ability to use URL=[MeasureName] is specifically built-into WebParser "child" measures, and plugins can never use dynamic variables other than that case. DynamicVariables=1 is ignored on all plugin measures.

* W= and H= have no effect on a button image. A Button meter cannot be resized, it will be the actual size of the bitmap used.

* Not sure I would use LeftMouseUpAction on the button. It works that way, but a button meter has a built-in ButtonCommand= statement. Up to you I guess, works either way, just seems easier to follow for someone looking at your skin code with ButtonCommand. The exception for me would be if I was using multiple commands on the Button meter like:

LeftMouseUpAction=!Execute ["http://cnn.com"]
MiddleMouseUpAction=!Execute ["http://msnbc.com"]

Then it would make the different commands and how you execute them more clear. Just a nitpick really... On a Button meter, LeftMouseUpAction and ButtonCommand are functionally identical.

* You don't need MouseActionCursor=1 on a Button meter, that state would be the default. You would only use MouseActionCursor=0 if you didn't want the hand cursor.

* As far as I can tell, AntiAlias=1 has no effect on a Button meter. Other image manipulation functions like GreyScale/ImageTint/ImageFlip/ColorMatrix(x) were added to Button meters, but I don't think AntiAlias was. Doesn't hurt anything to have it there, but I suspect it may be just an extra line of code you don't need.
User avatar
Scolex
Posts: 111
Joined: July 31st, 2010, 8:52 am

Re: measure + calc for button name why won't this work

Post by Scolex »

Thank you very much for all the tips it will save me many keystrokes.
I didn't figure the DynamicVariables=1 was needed since it isn't needed when used with #var1#.png.
Am I correct in assuming that if you are using [anymeasure]inaname.ext you have to use DynamicVariables

You know all this would be much easier if I could just VNC into your brain. :D
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: measure + calc for button name why won't this work

Post by jsmorley »

User avatar
Scolex
Posts: 111
Joined: July 31st, 2010, 8:52 am

Re: measure + calc for button name why won't this work

Post by Scolex »

Just so you know when I changed from
LeftMouseUpAction to ButtonCommand the bangs stopped working
Rainmeter v 2.0

for reference
didn't work
ButtonCommand=!Execute ["#MCxx#" "/MCC 10035, 3600000"]
works fine
LeftMouseUpAction=!Execute ["#MCxx#" "/MCC 10035, 3600000"]
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: measure + calc for button name why won't this work

Post by jsmorley »

Scolex wrote:Just so you know when I changed from
LeftMouseUpAction to ButtonCommand the bangs stopped working
Rainmeter v 2.0

for reference
didn't work
ButtonCommand=!Execute ["#MCxx#" "/MCC 10035, 3600000"]
works fine
LeftMouseUpAction=!Execute ["#MCxx#" "/MCC 10035, 3600000"]
Interesting. I didn't think there was any issue with variables, dynamic or not, with ButtonCommand. Have to look into that.