Re: Creating Buttons
Posted: June 7th, 2010, 4:48 pm
A button is a three "image" bitmap. As much animation as you can achieve in three images is the extent that you can have things appear to "move".
Code: Select all
[Variables]
Img.Num=1
[msButNum]
Measure=Calc
Formula=#Img.Num#+1>6?1:#Img.Num#+1
DynamicVariables=1
[msImgName]
Measure=Calc
Formula=-#Img.Num#
Substitute="-1":"ImgOne","-2":"ImgTwo","-3":"ImgThree","-4":"ImgFour","-5":"ImgFive","-6":"ImgSix"
DynamicVariables=1
[mtButton]
Meter=Button
ButtonImage=Image.png
ButtonCommand=!RainmeterSetVariable Img.Num [msButNum]
DynamicVariables=1
[mtImage]
Meter=Image
MeasureName=msImgName
ImageName=%1.png
Code: Select all
[Rainmeter]
BackgroundMode=1
AppVersion=14000
[Variables]
Img.Num=1
;= Character (position)=================
[msButNum]
Measure=Calc
Formula=#Img.Num#+1>6?1:#Img.Num#+1
DynamicVariables=1
[msImgName]
Measure=Calc
Formula=-#Img.Num#
Substitute="-1":"Char1","-2":"Char2","-3":"Char3","-4":"Char4","-5":"Char5","-6":"Char6"
DynamicVariables=1
[Char1]
Meter=IMAGE
X=195
Y=0
ImageName="002.png"
MeasureName=msImgName
Hidden=0
[Char2]
Meter=IMAGE
X=177
Y=0
ImageName="001.png"
MeasureName=msImgName
Hidden=1
[Char3]
Meter=IMAGE
X=70
Y=0
ImageName="3s.png"
MeasureName=msImgName
Hidden=1
[Char4]
Meter=IMAGE
X=194
Y=0
ImageName="004.png"
MeasureName=msImgName
Hidden=1
[Char5]
Meter=IMAGE
X=194
Y=0
ImageName="5.png"
MeasureName=msImgName
Hidden=1
[Char6]
Meter=IMAGE
X=194
Y=0
ImageName="6.png"
MeasureName=msImgName
Hidden=1
;==== Buttons =====================
[Button01]
Meter=Button
X=65
Y=286
ButtonImage=Anchor.png
ButtonCommand=!RainmeterSetVariable Img.Num [msButNum]
DynamicVariables=1
Code: Select all
[Rainmeter]
BackgroundMode=1
AppVersion=14000
[Variables]
Img.Num=1
Switch=2
;= Character (position)=================
[msButNum]
Measure=Calc
Formula=#Img.Num#+1>12?1:#Img.Num#+2
DynamicVariables=1
Disabled=1
[Switch]
Measure=CALC
Formula=#Switch#
IfAboveValue=0
IfAboveAction=!execute [!RainmeterToggleMeasure msButNum][!RainmeterSetVariable Switch (#Switch#-1)]
IfEqualValue=0
IfEqualAction=!execute [!RainmeterDisableMeasure Switch][!RainmeterSetVariable Img.Num [msButNum]]
DynamicVariables=1
Disabled=1
[msImgName]
Measure=Calc
Formula=-#Img.Num#
Substitute="-1":"Char1","-3":"Char2","-5":"Char3","-7":"Char4","-9":"Char5","-11":"Char6"
DynamicVariables=1
[Char]
Meter=IMAGE
X=195
Y=0
ImageName=[msImgName].png
DynamicVariables=1
Hidden=0
;==== Buttons =====================
[Button01]
Meter=Button
X=65
Y=286
ButtonImage=Anchor.png
ButtonCommand=!execute [!RainmeterEnableMeasure Switch]
DynamicVariables=1
Fair enough, I wasnt sure about that one.smurfier wrote:There is no reason to use dynamicvariables in the image meter.
Apologies, I did not read your code correctly, what you had should work fine. I misread your calculation as setting the variable one higher each update when it doesn't. :Embarrassed:smurfier wrote:Now, if you want it to automatically start cycling through through your images when you press the button, then my original code needs to be altered. If you want it cycle from one image to the next only when you press the button, my original code will work just fine if you put the image names in the substitute string, put the appropriate image name into the button, and then put in the x and y values.
Code: Select all
[Rainmeter]
BackgroundMode=1
AppVersion=14000
[Variables]
Img.Num=1
;= Character (position)=================
[msButNum]
Measure=Calc
Formula=#Img.Num#+1>6?1:#Img.Num#+1
DynamicVariables=1
[msImgName]
Measure=Calc
Formula=-#Img.Num#
Substitute="-1":"Char1","-2":"Char2","-3":"Char3","-4":"Char4","-5":"Char5","-6":"Char6"
DynamicVariables=1
;==== Buttons =====================
[Button01]
Meter=Button
X=65
Y=286
ButtonImage=Anchor.png
ButtonCommand=!RainmeterSetVariable Img.Num [msButNum]
DynamicVariables=1
[mtImage]
Meter=Image
MeasureName=msImgName
ImageName=%1.png