It is currently April 26th, 2024, 1:42 pm

Help: Switching wallpapers with a button

Get help with creating, editing & fixing problems with skins
Mino_el_Nukenin
Posts: 231
Joined: April 24th, 2020, 7:39 pm
Location: France

Re: Help: Switching wallpapers with a button

Post by Mino_el_Nukenin »

Thanks, it works but I have two problems :
- if I refresh the button skin, the wallpaper switches.
- When I turn on my PC, it automatically switches the wallpaper when rainmeter starts.

And next thing : what should I change if I want the groups to dissapear without delay and the wallpaper to switch to the first one (default) ?
Basically, I want my button to be like an ON/OFF button for my whole PC.

Code: Select all

[Variables]
@include=#@#\Config.inc
MyVar=1
Seconds1=3
Seconds2=2

[MeterButton]
Meter=Button
ButtonImage=#@#\Images\Shield Central Launcher Button\Shield Central Launcher Button.png
LeftMouseupAction=[!SetVariable MyVar "(0-#MyVar#)"][!UpdateMeasure "MeasureMyVar"][!UpdateMeter "#CURRENTSECTION#"][!Delay (1000*#Seconds1#)][!ToggleGroup "Frame+Logo"][!Delay (1000*#Seconds2#)][!ToggleGroup "Module"]
Antialias=1
DynamicVariables=1

[MeasureMyVar]
Measure=Calc
Formula=#MyVar#
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!SetWallpaper "#@#\Wallpapers\Wallpaper - inactive.png" Fill]
IfFalseAction=[!SetWallpaper "#@#\Wallpapers\Wallpaper - Lockscreen.png" Fill]
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help: Switching wallpapers with a button

Post by balala »

Mino_el_Nukenin wrote: April 26th, 2020, 9:06 pm - if I refresh the button skin, the wallpaper switches.
- When I turn on my PC, it automatically switches the wallpaper when rainmeter starts.
Normally, because the MyVar variable has an initial value. When you refresh the skin, it reads the value set into the [Variables] section and acts accordingly, setting the appropriate wallpaper, no matter what was set before. When you turn on the computer the same thing goes on, but only when Rainmeter starts and it loads the skin.
Possible solution: you could modify the saved value of the MyVar variable into the [Variables] section, which means that if you refresh the skin (or when you turn on the computer), it sets back the last wallpaper, because the skin stores the variable. In this case when you refresh the skin, it remembers the previous setting and acts accordingly. Interested?
Mino_el_Nukenin wrote: April 26th, 2020, 9:06 pm And next thing : what should I change if I want the groups to dissapear without delay and the wallpaper to switch to the first one (default) ?
Remove the !Delay bang(s).
Mino_el_Nukenin wrote: April 26th, 2020, 9:06 pm Basically, I want my button to be like an ON/OFF button for my whole PC.
I suppose by this you mean you wanna get a button to change the wallpaper and toggle the skins. But this is done, isn't it?
Mino_el_Nukenin
Posts: 231
Joined: April 24th, 2020, 7:39 pm
Location: France

Re: Help: Switching wallpapers with a button

Post by Mino_el_Nukenin »

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.
User avatar
Yincognito
Rainmeter Sage
Posts: 7171
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help: Switching wallpapers with a button

Post by Yincognito »

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?
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Mino_el_Nukenin
Posts: 231
Joined: April 24th, 2020, 7:39 pm
Location: France

Re: Help: Switching wallpapers with a button

Post by Mino_el_Nukenin »

Wow, thanks really for the explanation.
I didn't understand that (1-#MyVar#) was a mathematical formula like (1-0)=1, I thought it was just showing the two posibilities for the variable to be. Now I get how the thing works for the switch between the two variables.

Thanks also for the explanation for the delay part, it's very clear. Now I just nee to get use to the way thing work with these formulas. It's very logical but kinda hard to know what to put, where to put at first.
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help: Switching wallpapers with a button

Post by balala »

Ok, you got solved all questions, by Yincognito? Hope you did.
Mino_el_Nukenin wrote: April 27th, 2020, 4:50 pm I didn't understand that (1-#MyVar#) was a mathematical formula like (1-0)=1, I thought it was just showing the two posibilities for the variable to be. Now I get how the thing works for the switch between the two variables.
Yes, that's a formula, which alternated the two possible values of the variable (0 and respectively 1). Note that similarly any value and 0 could be alternated, for instance a [!setVariable MyVar "(32-#MyVar#)"] alternates the value of the MyVar between 0 and 32. This is a commonly used procedure to get the value of a variable alternated.
Mino_el_Nukenin wrote: April 27th, 2020, 4:50 pm Thanks also for the explanation for teh delay part, it's very clear. Now I just nee to get use to the way thing work with this formulas. It's very logical but kinda hard to know what to put, where to put at first.
If you keep working, you very soon will get used with many things used in Rainmeter. Just keep working, to encounter many different situations.
Mino_el_Nukenin
Posts: 231
Joined: April 24th, 2020, 7:39 pm
Location: France

Re: Help: Switching wallpapers with a button

Post by Mino_el_Nukenin »

Yes everything is working fine.

I'm actually using a skin already made, but making some change myself and exporting what I need my own skin file (it's pretty hard since all the skins are "linked" to a big Options.ini, so I'm getting confused with the numerous codes when I want to only use part a skin.)

I'm trying to create a [meter] with an animated .gif, but the commandprompt to transform the .gif in .png was'nt working. So kinda stuck here with cmd.exe
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help: Switching wallpapers with a button

Post by balala »

Mino_el_Nukenin wrote: April 27th, 2020, 5:44 pm I'm actually using a skin already made, but making some change myself and exporting what I need my own skin file (it's pretty hard since all the skins are "linked" to a big Options.ini, so I'm getting confused with the numerous codes when I want to only use part a skin.)
We all do this. It's the essence of all this work and all the time getting things changing and getting new ideas, which led to new changes and so on.
Mino_el_Nukenin wrote: April 27th, 2020, 5:44 pm I'm trying to create a [meter] with an animated .gif, but the commandprompt to transform the .gif in .png was'nt working. So kinda stuck here with cmd.exe
If you wanna working with this, you have to know about this. As you can see in the description, Rainmeter can't display animated GIFs, the described procedure is needed to be applied in order to get the animation.
Mino_el_Nukenin
Posts: 231
Joined: April 24th, 2020, 7:39 pm
Location: France

Re: Help: Switching wallpapers with a button

Post by Mino_el_Nukenin »

Yeah I was refering to this link actually.
But I can't manage to do the first step : the command line doesn't work. I've downloaded ImageQuick already. I have a .gif file all set.

Here is what the cmd.exe says :

Code: Select all

C:\Users\geoff>convert -coalesce "MainframeBoot.gif" "MainframeBoot.png"
Paramètre non valide - "MainframeBoot.gif"
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help: Switching wallpapers with a button

Post by balala »

Mino_el_Nukenin wrote: April 27th, 2020, 7:13 pm Yeah I was refering to this link actually.
But I can't manage to do the first step : the command line doesn't work. I've downloaded ImageQuick already. I have a .gif file all set.

Here is what the cmd.exe says :

Code: Select all

C:\Users\geoff>convert -coalesce "MainframeBoot.gif" "MainframeBoot.png"
Paramètre non valide - "MainframeBoot.gif"
I suppose you have properly installed ImageMagick, right? If you have, try to specify the complete path of both the animated .gif and the .png file you have to create, for instance: convert -coalesce "d:\MainframeBoot.gif" "d:\MainframeBoot.png"