It is currently April 27th, 2024, 9:39 am

Problem with !SetWallpaper bang

Get help with creating, editing & fixing problems with skins
Virgil
Posts: 13
Joined: October 14th, 2011, 1:16 pm

Problem with !SetWallpaper bang

Post by Virgil »

Hello,

It's my first message here and I need your help. I an trying to create a skin for Rainmeter but I can't deal with the !SetWallpaper bang.
I will try to explain what I want to do. But first, i want to apologize for english mistakes. It's not my native language and it's a bit hard for me to explain correctly what I have in mind. I hope you will understand what I mean.

So, I want to make a button with text. The text is something like "Show Wallpaper 2". And I have 2 different wallpapers (wallpaper1 and wallpaper2). When I click on the button's text, wallpaper2 replaces wallpaper1 and text becomes "show wallpaper 1". Then, when I click on "show wallpaper1", wallpaper1 replaces wallpaper2.

I've made a code that seems to work. But not always. Sometimes it works correctly, sometimes it doesn't work (I mean wallpaper2 don't replace wallpaper1) and I can't find a clue to solve my problem.

Here is the code I have made:

Code: Select all


[MeasureGetWallpaper]
Measure=Plugin
Plugin=QuotePlugin
PathName=#ImagesPath#\Wallpapers
FileFilter=*.jpg;*.png
UpdateDivider=60

[MeasureGetWallpaper2]
Measure=Plugin
Plugin=QuotePlugin
PathName=#ImagesPath#\Wallpapers
FileFilter=*.jpg;*.png
UpdateDivider=60

[BUTTON]
Meter=Image
X=40
Y=40
ImageName=#ImagesPath#\bubblePanel.png

[BUTTONTITLE]
Meter=String
X=68
Y=55
FontFace=#font#
FontColor=0,0,0,255
FontSize=12
StringAlign=Left
AntiAlias=1
Text=show wallpaper 2
MeasureName=MeasureGetWallpaper
LeftMouseUpAction=!Execute [!UpdateMeasure MeasureGetWallpaper][!SetWallpaper "[MeasureGetWallpaper]"][!ShowMeter BUTTONTITLE2][!HideMeter BUTTONTITLE][!Redraw]

[BUTTONTITLE2]
Meter=String
X=68
Y=55
FontFace=#font#
FontColor=0,0,0,255
FontSize=12
StringAlign=Left
AntiAlias=1
Text=show wallpaper 1
Hidden=1
MeasureName=MeasureGetWallpaper2
LeftMouseUpAction=!Execute [!UpdateMeasure MeasureGetWallpaper][!SetWallpaper "[MeasureGetWallpaper2]"][!HideMeter BUTTONTITLE2][!ShowMeter BUTTONTITLE][!Redraw]
I would be glad if someone could help me to improve the code and to make it definitively correct. Thanks :D
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Problem with !SetWallpaper bang

Post by Kaelri »

The problem is that [MeasureGetWallpaper] and [MeasureGetWallpaper2] both do the same thing. You've set them up to return a random image from the "Wallpapers" folder, which means that sometimes they're going to return the same image. I don't know exactly how you want this to work, but if you put your images in two separate folders, you won't get any duplicates.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Problem with !SetWallpaper bang

Post by jsmorley »

The point of using QuotePlugin in many of the sample skins that use !SetWallpaper is to select a random wallpaper out of a folder containing a bunch of them. Since you want to just toggle between two files, using two QuotePlugin measures is both overkill and will have the undesired effect of both of them returning the same file name about 50% of the time. I would not use QuotePlugin at all for this.

Here is a reasonably simple approach. Just name the two files "Wallpaper0.jpg" and "Wallpaper1.jpg" and this will toggle between the two of them when you click on the meter:

Code: Select all

[Variables]
Num=0

[MeterButtonText]
Meter=String
FontSize=13
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Wallpaper #Num#
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Num (1-#Num#)][!SetWallpaper "#@#Images\Wallpaper#Num#.jpg"]
Virgil
Posts: 13
Joined: October 14th, 2011, 1:16 pm

Re: Problem with !SetWallpaper bang

Post by Virgil »

Oh yeahhh!! It works better now. Thanks a lot for your help.