It is currently March 29th, 2024, 8:35 am

Using variables for condition checking

Get help with creating, editing & fixing problems with skins
Emperor_Koala
Posts: 3
Joined: August 19th, 2017, 3:55 pm

Using variables for condition checking

Post by Emperor_Koala »

Hi all,
I'm trying to modify the skin "Arrow Launcher", so that it only opens and closes when clicked. The default behavior is when the user hovers over the launcher, but I want to be able to click instead. I decided to use variables to check if the menu is open before closing, and if its closed before opening, but I can't get it to work properly.

Here's my current code for anyone who needs it

Code: Select all

[Rainmeter]
Author=KoalaKing
Update=1000

[Metadata]
Name=Arrow Launcher
Config=
Description= Simple App and 
Instructions=
Version=1.0
Tags=
License=
Variant=
Preview=Preview:png


[Variables]
@include="#CURRENTPATH#\Variables.txt"
@include2="#CURRENTPATH#\Arrows\#skin#\Fontcolor.txt"
meterGroupState=0

[Background]
Meter=IMAGE
X=0
Y=0
W=250
H=556
;SolidColor==0,0,0,1
DynamicVariables=1
LeftMouseUpAction=#meterGroupState#=1?[!HideMeterGroup 1][!HideMeter Arrowhover][!ShowMeter Arrow][!Redraw][!SetVariable "meterGroupState" 0]:[!SetVariable "meterGroupState" 1]

[Arrow]
Meter=IMAGE
ImageName=Autodesk.png
Path="C:\Users\matth\Documents\Rainmeter\Skins\Honeycomb\@Resources\Images\"
H=90
Y=512
X=175
Hidden=0
DynamicVariables=1
LeftMouseUpAction=#meterGroupState#=0?[!ShowMeterGroup 1][!HideMeter Arrow][!ShowMeter Arrowhover][!Redraw][!SetVariable "meterGroupState" 1]:[!SetVariable "meterGroupState" 0]


[Arrowhover]
Meter=IMAGE
ImageName=Autodesk.png
Path="C:\Users\matth\Documents\Rainmeter\Skins\Honeycomb\@Resources\Images\"
H=90
Y=512
X=175
Hidden=1
DynamicVariables=1
LeftMouseUpAction=#meterGroupState#=0?[!ShowMeterGroup 1][!Redraw][!SetVariable "meterGroupState" 1]:[!SetVariable "meterGroupState" 0]

;Appicons>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

[Icon1]
Meter=IMAGE
ImageName="C:\Users\matth\Documents\Rainmeter\Skins\Honeycomb\@Resources\Images\AutoCAD.png"
LeftMouseUpAction=["C:\Program Files\Autodesk\AutoCAD 2016\acad.exe"  /product ACAD /language "en-US"]
Y=415
X=195
H=50
Hidden=1
Group=1

[Icon2]
Meter=IMAGE
ImageName="C:\Users\matth\Documents\Rainmeter\Skins\Honeycomb\@Resources\Images\Inventor.png"
LeftMouseUpAction=["C:\Program Files\Autodesk\Inventor 2017\Bin\Inventor.exe"]
Y=#IconDistance#r
X=195
H=50
Hidden=1
Group=1
I am also modifying it so that it fits the "Honeycomb" theme but that all seems to work. I just can't figure out how to check and modify variables using the LeftMouseUpAction.

Any help would be greatly appreciated. Thanks!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using variables for condition checking

Post by jsmorley »

I just can't dig into "Arrow Launcher" and certainly not "Honeycomb", but in general, you can toggle the "visibility" of a meter with a mouse click using something like:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Variables]
Toggle=1

[MeterClicker]
Meter=Image
W=40
H=40
SolidColor=47,47,47,255
LeftMouseUpAction=[!SetVariable Toggle "(1-#Toggle#)"][!UpdateMeter *][!Redraw]
DynamicVariables=1

[MeterText]
Meter=String
Y=10R
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=I'm visible
Hidden=#Toggle#
DynamicVariables=1
So you are simply toggling the value of the variable #Toggle# between 1 and 0. That is used by the Hidden option on the String meter.
Emperor_Koala
Posts: 3
Joined: August 19th, 2017, 3:55 pm

Re: Using variables for condition checking

Post by Emperor_Koala »

Thank you! Functionally this is perfect, though for some reason it has a bit of lag time between the click and the toggle. Is that just because of the method or is it something else?

Either way thanks again!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using variables for condition checking

Post by jsmorley »

Emperor_Koala wrote:Thank you! Functionally this is perfect, though for some reason it has a bit of lag time between the click and the toggle. Is that just because of the method or is it something else?

Either way thanks again!
The "lag" is the time between setting the variable #Toggle# and the time the String meter will use it, which will be on the next regular skin update, or in the case of my skin up to one second later.

I control that with the [!UpdateMeter *][!Redraw] on the end of the LeftMouseUpAction option. That forces the String meter to immediately update, and use the current value of #Toggle# I just set.

Note that I use [!UpdateMeter *] so I update both the String meter, and the Image meter I'm using to toggle the variable. That is so if I click "quickly", the value of #Toggle# the LeftMouseUpAction is using is the current one I just set, and not the value from the previous skin update.

There is no "lag" in the example I posted.
Emperor_Koala
Posts: 3
Joined: August 19th, 2017, 3:55 pm

Re: Using variables for condition checking

Post by Emperor_Koala »

Oh ok. Thank you so much for the help!