It is currently March 29th, 2024, 2:05 pm

Icon that sets wallpapers

Get help with creating, editing & fixing problems with skins
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Icon that sets wallpapers

Post by J0wNs »

Ok so I created an icon skin and I wanted to use it as a tool to cycle through some wallpapers.
The problem is that I don't know much about coding and I'm stuck here, with the option to only set one wallpaper.
Here's the code:
LeftMouseUpAction=[!SetWallpaper "#@#Wallpapers\Forest2.png" Fill]

Can anyone help me? :???:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Icon that sets wallpapers

Post by balala »

J0wNs wrote:Ok so I created an icon skin and I wanted to use it as a tool to cycle through some wallpapers.
The problem is that I don't know much about coding and I'm stuck here, with the option to only set one wallpaper.
Here's the code:
LeftMouseUpAction=[!SetWallpaper "#@#Wallpapers\Forest2.png" Fill]
I suppose the posted LeftMouseUpAction option works and sets the appropriate wallpaper, right (supposing you have the image in the proper location)?
How many images have you there, which would have to be set as wallpaper? And what you would like: to set a new wallpaper on every click to the appropriate icon? Please give us a bit more information.
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Re: Icon that sets wallpapers

Post by J0wNs »

Right now I have 2 wallpapers, but I'd like to add more in the future. Basically yes, I want with just a click to set the next wallpaper in the folder. I've tried the QuotePlugin but it's all random, and it often sets the wallpaper that's already on, I guess, because sometimes when I click it doesn't change my wallpaper (apparently).
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Icon that sets wallpapers

Post by balala »

J0wNs wrote:Right now I have 2 wallpapers, but I'd like to add more in the future. Basically yes, I want with just a click to set the next wallpaper in the folder. I've tried the QuotePlugin but it's all random, and it often sets the wallpaper that's already on, I guess, because sometimes when I click it doesn't change my wallpaper (apparently).
Ok, if you have a preferred order for the images, do the followings:
  • First create two variables in the [Variables] section. Wallpaper is a variable which controls which image is set as wallapaer, while NumOfWallpapers is the total number of images which you'd like to use:

    Code: Select all

    [Variables]
    Wallpaper=0
    NumOfWallpapers=XX
    (add the concrete number of images).
  • Now add the following Calc measure to your code:

    Code: Select all

    [MeasureWallpaper]
    Measure=Calc
    Formula=#Wallpaper#
    IfCondition=(#CURRENTSECTION#=0)
    IfTrueAction=[!SetWallpaper "#@#Wallpapers\FIRST-WALLPAPER-IMAGE.png" "Fill"]
    IfCondition2=(#CURRENTSECTION#=1)
    IfTrueAction2=[!SetWallpaper "#@#Wallpapers\SECOND-WALLPAPER-IMAGE.png" "Fill"]
    IfCondition3=(#CURRENTSECTION#=2)
    IfTrueAction3=[!SetWallpaper "#@#Wallpapers\THIRD-WALLPAPER-IMAGE.png" "Fill"]
    ...
    DynamicVariables=1
    Add as many IfCondition / IfTrueAction option pairs, as many are needed, to cover all images you'd like to set as wallpaper.
  • Finally modify the LeftMouseUpAction of the (probably) Image meter (change the LeftMouseUpAction=[!SetWallpaper "#@#Wallpapers\Forest2.png" Fill] option), as it follows: LeftMouseUpAction=[!SetVariable Wallpaper "((1+#Wallpaper#)%#NumOfWallpapers#)"][!UpdateMeasure "MeasureWallpaper"][!UpdateMeter "#CURRENTSECTION#"]. Also add a DynamicVariables=1 option to this meter, whatever it would be. Make sure to not forget this option, otherwise the skin will change the wallpaper only once.
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Re: Icon that sets wallpapers

Post by J0wNs »

Works like a charm, thanks!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Icon that sets wallpapers

Post by balala »

J0wNs wrote:Works like a charm, thanks!
Great, good job.
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Re: Icon that sets wallpapers

Post by J0wNs »

balala wrote:Great, good job.
Is there a way to preserve my current wallpaper after I refresh the skin?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Icon that sets wallpapers

Post by balala »

J0wNs wrote:Is there a way to preserve my current wallpaper after I refresh the skin?
Yep, it is. Just extend the used LeftMouseUpAction, as it follows: LeftMouseUpAction=[color=#FF0000][!WriteKeyValue Variables Wallpaper "((1+#Wallpaper#)%#NumOfWallpapers#)"][/color][!SetVariable Wallpaper "((1+#Wallpaper#)%#NumOfWallpapers#)"][!UpdateMeasure "MeasureWallpaper"][!UpdateMeter "#CURRENTSECTION#"].
The newly added !WriteKeyValue bang writes the appropriate value of the Wallpaper variable into the [Variables] section of the skin. This way, when you refresh the skin, it'll reuse the written value of the variable. This means that practically at refresh, the skin sets again the same wallpaper and you won't see any change.
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Re: Icon that sets wallpapers

Post by J0wNs »

Thanks a lot!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Icon that sets wallpapers

Post by balala »

Glad to help (if I did).