Mino_el_Nukenin wrote: ↑April 27th, 2020, 1:49 pm
I'm not sure I explained myself correctly.
My main button will be "like an On/OFF" switch, I mean it will switch the wallpaper (from the Lockscreen wallpaper which should be the default wallpaper to the Inactive wallpaper) and toggle my skins when I click it once (when I turn on my PC). Then it needs to switch the inactive wallpaper back to default wallpaper and turn off the skins when I click again.
If I remove the [!Delay] bangs I won't have the delay I want when I first click. I only want the delay when "switching on" and none when "switching off" my button.
I hope i'm clearer.
> Currently, the button works, but the wallpaper switches automatically without clicking the button when I turn PC on (even if I clicked the button before turning off the PC) or if I refresh the button skin.
So yes, I just need to have a code telling Rainmeter that Lockscreen Wallpaper is to be the default wallpaper when turn on the PC.
The first problem in your code is that you have changed the way the
MyVar variable was behaving, compared to the advice given by balala
here. In other words, you incorrectly replaced
MyVar=0 with
MyVar=1 in the [Variables] section and the formula from
(1-#MyVar#) to
(0-#MyVar#). If you do the math, it's pretty obvious why it didn't work in the first place, since when you first click the button, MyVar will become
(0-1), aka
-1, instead of
1 how it should have been (so basically, the toggling between
0 and
1 due to the formula is never happening anymore). Not to mention that the initial value of the variable in the
[Variables] section was the complete opposite (
1 instead of
0), of course.
That being said, some code had to be added to complete the job, mainly adding an
UpdateDivider=-1 to
[MeasureMyVar] so that the measure only updates itself once (i.e. the first time, basically making it a measure updated only on demand and not automatically) and then adding an
IfConditionMode=1 so that the IfCondition test there is executed every time we update the measure (which now happens on demand, aka only when we need it to, as explained above).
Thus, the code becomes:
Code: Select all
[Variables]
@include=#@#\Config.inc
MyVar=0
Seconds1=3
Seconds2=2
[MeterButton]
Meter=Button
ButtonImage=#@#\Images\Shield Central Launcher Button\Shield Central Launcher Button.png
LeftMouseupAction=[!SetVariable MyVar "(1-#MyVar#)"][!UpdateMeasure "MeasureMyVar"][!UpdateMeter "#CURRENTSECTION#"][!Delay ((1-#MyVar#)*1000*#Seconds1#)][!ToggleGroup "Frame+Logo"][!Delay ((1-#MyVar#)*1000*#Seconds2#)][!ToggleGroup "Module"]
Antialias=1
DynamicVariables=1
[MeasureMyVar]
Measure=Calc
Formula=#MyVar#
UpdateDivider=-1
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!SetWallpaper "#@#\Wallpapers\Wallpaper - inactive.png" Fill]
IfFalseAction=[!SetWallpaper "#@#\Wallpapers\Wallpaper - Lockscreen.png" Fill]
IfConditionMode=1
DynamicVariables=1
Notice that we've added the
(1-#MyVar#) part to the !Delay formulas as well. This is because you wanted to "toggle" between a delay and no delay on every mouse click. What happens here is that on click, things alternate between the following:
a)
MyVar = 0 =>
Delay = (1 - 0) * ActualDelayValue = ActualDelayValue ... but then MyVar also becomes
(1 - #MyVar#) = (1 - 0) = 1 during the same click
b)
MyVar = 1 => Delay = (1 - 1) * ActualDelayValue = 0 ... but then MyVar also becomes
(1 - #MyVar#) = (1 - 1) = 0 during the same click
So at a) we delay things for the actual delay duration, while at b) we don't delay them at all, since the delay is 0. You get the point, right?