It is currently March 29th, 2024, 5:33 am

Wallpaper Changer

Get help with creating, editing & fixing problems with skins
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Wallpaper Changer

Post by zivallh »

Hello Guys

I have this skin which is a wallpaper changer from Unsplash once you click the Unsplash button that downloads a new random picture and put it as background.

there is another button to download that picture, the problem is here in the code everytime I refresh the skin the count in variables +1 number without saving a picture so each time the skin is refreshed the count will run and set a new variable in the count anyway to fix this issue?

I want it only If I hit the download button make a new count number in variables, so the pictures will save sequentialy without a gap number between them!

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1

[Variables]

Start=1
Count=70
Path=Unsplash/

[MeasureCount]
Measure=Calc
Formula=(( #Start# >= 1 ) ? #Count# : ( MeasureCount + 1 - #Start# ))
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(.)$":"0\1"
IfCondition=(#Start#=1)
IfTrueAction=[!Delay "1000"][!SetVariable Start "0"][!UpdateMeasure "#CURRENTSECTION#"]
OnChangeAction=[!SetVariable Count "[MeasureCount]"][!WriteKeyValue Variables Count "[MeasureCount]"][!UpdateMeasure "MeasureRun"]
UpdateDivider=-1

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Parameter=Copy "[Webparser]" "#Path#\Unsplash#Count#.jpg"
State=Hide
DynamicVariables=1

[WebParser]
Measure=Plugin
Plugin=WebParser
URL=https://source.unsplash.com/random/#SCREENAREAWIDTH#x#SCREENAREAHEIGHT#/
UpdateRate=-1
Download=1
DownloadFile=Unsplash.jpg
FinishAction=[!SetOption Webparser FinishAction """[!SetWallpaper "DownloadFile\Unsplash.jpg"]"""]

[Background]
Meter=Shape
Shape=Rectangle 0,0,160,45,10 | StrokeWidth 1 | StrokeColor 255,255,255,0 | Fill LinearGradient Gradient
Gradient=180 | 255,255,255,0 ; 0.1 | 255,255,255,#Alpha2# ; 1
DynamicVariables=1

[Unsplash]
Meter=String
Text=UnSplash
FontFace=Gilroy ExtraBold
FontSize=14
X=15
Y=23
StringStyle=Normal
StringAlign=LeftCenter
AntiAlias=1
FontColor=255,255,255
LeftMouseUpAction=[!CommandMeasure WebParser Update][!Redraw]
DynamicVariables=1

[Download]
Meter=Image
ImageName=#@#Images/Download.png
X=30
Y=13
W=20
LeftMouseUpAction=[!CommandMeasure "MeasureRun" "Run"][!UpdateMeasure "MeasureCount"]["#SKINSPATH#\UnsplashForRainmeter\Unsplash"]
DynamicVariables=1
User avatar
tass_co
Posts: 511
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Wallpaper Changer

Post by tass_co »

zivallh wrote: August 27th, 2022, 10:38 pm Hello Guys

I have this skin which is a wallpaper changer from Unsplash once you click the Unsplash button that downloads a new random picture and put it as background.

there is another button to download that picture, the problem is here in the code everytime I refresh the skin the count in variables +1 number without saving a picture so each time the skin is refreshed the count will run and set a new variable in the count anyway to fix this issue?

I want it only If I hit the download button make a new count number in variables, so the pictures will save sequentialy without a gap number between them!
If you add the #Count# variable to the downloaded file name, it will save as sequential numbers.
But first you have to save the Count variable as 0.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1

[Variables]

Start=1
Count=0
Path=Unsplash\

[MeasureCount]
Measure=Calc
Formula=(( #Start# >= 1 ) ? #Count# : ( MeasureCount + 1 - #Start# ))
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(.)$":"0\1"
IfCondition=(#Start#=1)
IfTrueAction=[!Delay "1000"][!SetVariable Start "0"][!UpdateMeasure "#CURRENTSECTION#"]
OnChangeAction=[!SetVariable Count "[MeasureCount]"][!WriteKeyValue Variables Count "[MeasureCount]"][!UpdateMeasure "MeasureRun"]
UpdateDivider=-1

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Parameter=Copy "[Webparser]" "#Path#\Unsplash#Count#.jpg"
State=Hide
DynamicVariables=1

[WebParser]
Measure=Plugin
Plugin=WebParser
URL=https://source.unsplash.com/random/#SCREENAREAWIDTH#x#SCREENAREAHEIGHT#/
UpdateRate=-1
Download=1
DownloadFile=Unsplash#Count#.jpg ;<=================THIS LINE
FinishAction=[!SetOption Webparser FinishAction """[!SetWallpaper "DownloadFile\Unsplash#Count#.jpg"]"""]
DynamicVariables=1

[Background]
Meter=Shape
Shape=Rectangle 0,0,160,45,10 | StrokeWidth 1 | StrokeColor 255,255,255,0 | Fill LinearGradient Gradient
Gradient=180 | 255,255,255,0 ; 0.1 | 255,255,255,#Alpha2# ; 1
DynamicVariables=1

[Unsplash]
Meter=String
Text=UnSplash
FontFace=Gilroy ExtraBold
FontSize=14
X=15
Y=23
StringStyle=Normal
StringAlign=LeftCenter
AntiAlias=1
FontColor=255,255,255
LeftMouseUpAction=[!CommandMeasure WebParser Update][!Redraw]
DynamicVariables=1

[Download]
Meter=Image
ImageName=#@#Images/Download.png
X=30
Y=13
W=20
LeftMouseUpAction=[!CommandMeasure "MeasureRun" "Run"][!UpdateMeasure "MeasureCount"]["#SKINSPATH#\UnsplashForRainmeter\Unsplash"]
DynamicVariables=1

You can also use another technique.
1. Capture the name of the last file in the folder with the FileView plugin
2. Find the number found in the filename with Substitute
3. For the Count formula, add +1 to the number you caught with Substitute.

It should be like the code below but im not sure.
I just haven't had a chance to try the code.

Code: Select all

[MeaFolder]
Measure=Plugin
Plugin=FileView
Path= ; Download files folder
ShowDotDot=0
ShowFolder=0
SortType=Date
SortDateType=Created
SortAscending=0
Count=1
Extensions="jpg"
DynamicVariables=1


[MeaLastFile]
Measure=Plugin
Plugin=FileView
Path=[MeaFolder]
Type=Filename
Index=1
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(.*)\\(.*)":"\2"

[CalcCount]
Measure=Calc
Formula=(([MeaLastFolder])+1)

[WebParser]
Measure=Plugin
Plugin=WebParser
URL=https://source.unsplash.com/random/#SCREENAREAWIDTH#x#SCREENAREAHEIGHT#/
UpdateRate=-1
Download=1
DownloadFile=Unsplash[CalcCount].jpg
FinishAction=[!SetOption Webparser FinishAction """[!SetWallpaper "DownloadFile\Unsplash[CalcCount].jpg"]"""]
DynamicVariables=1
Last edited by tass_co on August 27th, 2022, 11:32 pm, edited 2 times in total.
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: Wallpaper Changer

Post by zivallh »

#count# is already there if you can check the code, it’s saving sequentially but if the skin is reloaded is gonna put a one number gap without even hit the save button, I’ll try your second method and let you know thank you))
User avatar
tass_co
Posts: 511
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Wallpaper Changer

Post by tass_co »

zivallh wrote: August 27th, 2022, 11:30 pm #count# is already there if you can check the code, it’s saving sequentially but if the skin is reloaded is gonna put a one number gap without even hit the save button, I’ll try your second method and let you know thank you))
It wasn't available in the code you posted, I added it.

Sorry, I don't have time to try the code right now.
If you try and write the result, we will act accordingly :thumbup:
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: Wallpaper Changer

Post by zivallh »

I tried but it didn’t work out maybe something is missing, now keep saving only one picture, please try once you have time and let me know :thumbup:
User avatar
tass_co
Posts: 511
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Wallpaper Changer

Post by tass_co »

zivallh wrote: August 28th, 2022, 12:04 am I tried but it didn’t work out maybe something is missing, now keep saving only one picture, please try once you have time and let me know :thumbup:
I completely changed your existing code.
I have set the downloaded filenames as Date/Time.
Thus, a Counter will not be needed.
I also changed the file unicode format to UTF-16 LE BOM. That's why I'm sharing the Skin file.
Since I cannot assign a path variable to FileView Plugin, you have to change the following line from the ini file to your own address after installing the Skin (Path part)
Wallpaper_1.0.rmskin

Code: Select all

[MeaFolder]
Measure=Plugin
Plugin=FileView
Path="C:\Users\CHANGE_PATH\Documents\Rainmeter\Skins\003\DownloadFile"
.
.

Full code (in order to be developed)

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1

[Variables]


[MeaTime]
Measure=Time
Format=%d.%m.%Y - %H.%M.%S

[MeaFolder]
Measure=Plugin
Plugin=FileView
Path="C:\Users\CHANGE_PATH\Documents\Rainmeter\Skins\003\DownloadFile"
ShowDotDot=0
ShowFolder=0
SortType=Date
SortDateType=Created
SortAscending=0
Count=1
DynamicVariables=1

[MeaLastFile]
Measure=Plugin
Plugin=FileView
Path=[MeaFolder]
Type=FilePath
Index=1
DynamicVariables=1


[WebParser]
Measure=Plugin
Plugin=WebParser
URL=https://source.unsplash.com/random/#SCREENAREAWIDTH#x#SCREENAREAHEIGHT#/
UpdateRate=-1
Download=1
DownloadFile=[MeaTime].jpg
FinishAction=[!SetOption Webparser FinishAction """[!SetWallpaper "[MeaLastFile]"]"""]
DynamicVariables=1

[Background]
Meter=Shape
Shape=Rectangle 0,0,160,45,10 | StrokeWidth 1 | StrokeColor 255,255,255,0 | Fill LinearGradient Gradient
Gradient=180 | 255,255,255,0 ; 0.1 | 255,255,255,#Alpha2# ; 1
DynamicVariables=1

[Unsplash]
Meter=String
Text=UnSplash
FontFace=Gilroy ExtraBold
FontSize=14
X=15
Y=23
StringStyle=Normal
StringAlign=LeftCenter
AntiAlias=1
FontColor=255,255,255
LeftMouseUpAction=[!CommandMeasure WebParser Update][!Redraw]
DynamicVariables=1

[Download]
Meter=Image
ImageName=[MeaLastFile]
X=30
Y=13
W=20
LeftMouseUpAction=[!UpdateMeasure "MeasureCount"]
DynamicVariables=1
You do not have the required permissions to view the files attached to this post.
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: Wallpaper Changer

Post by zivallh »

I have attached the full skin for you

"UnsplashForRainmeterMine" The original file
"UnsplashForRainmeterMine - 02" The modified Code

I like the idea of renaming each picture

However, the problem now with your code now is downloading each picture, without hitting the download button and even if you refresh the skin is downloading a new picture and doesn't sit it as wallpaper

The idea is to change the wallpaper and if you like that picture, you press the download button to save

my issue with the code is each time you refresh the skin add a new number to the "count" without pressing the download button, which makes a gap between the names
You do not have the required permissions to view the files attached to this post.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Wallpaper Changer

Post by eclectic-tech »

You can use the FileView plugin to count the number of files in your Unsplash folder and use a Calc measure to add 1 to that value. That way the filename will always be 1 above the number of images you have saved. The downside is if you manually delete one of those images, and do not rename them all in sequence, you will have gaps in the names AND the next saved download will overwrite previous images with names having numbers higher than the number of images counted by the plugin.

Here is your code modified to use the Fileview plugin to monitor the saved images and control the Count. I set the value of Count to the Fileview child measure [MeasureFileCount], but I do not use the Count variable, instead when saving the image, the measure value is used; It will save the current download as the next image number based on the value of [MeasureCount]

I saved this as 'UnplashForRainmeterMine - 03.ini, so I could refer back to your version (- 02).

Code: Select all

[Rainmeter]
Update=1000
Group=Switch
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
ContextTitle=Setting
ContextAction=[!ActivateConfig "UnsplashForRainmeter\Setting"]

MouseScrollUpAction=[!SetVariable Scale "(#Scale#+#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#+#ScrollMouseIncrement#)"][!Refresh] 
MouseScrollDownAction=[!SetVariable Scale "(#Scale#-#ScrollMouseIncrement# < 0.2 ? 0.2 : #Scale#-#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#-#ScrollMouseIncrement# < 0.2 ? 0.2 : #Scale#-#ScrollMouseIncrement#)"][!Refresh]

[Metadata]
Name=Unsplash
Author=XukaKun (khanhas@reddit, khanhas#3928@discord)
Information=Download and set wallpapers from famous Unsplash photo library automatically.
Version=1.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]
Scale=0.9
ScrollMouseIncrement=0.05

Start=0
Count=[MeasureFileCount]
Path=Unsplash/

Alpha1=0
Alpha2=0
Speed=5
Action=[!UpdateMeasure MeasureFader][!UpdateMeter *][!Redraw]

; ----------------------------------------- Fade

[MeasureFader]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat FadeIn1,#Speed#,20
FadeIn1=[!SetVariable Alpha1 "(Clamp(#Alpha1#+15,0,255))"]#Action#
ActionList2=Repeat FadeOut1,#Speed#,20
FadeOut1=[!SetVariable Alpha1 "(Clamp(#Alpha1#-15,0,255))"]#Action#
ActionList3=Repeat FadeIn2,#Speed#,20
FadeIn2=[!SetVariable Alpha2 "(Clamp(#Alpha2#+5,0,255))"]#Action#
ActionList4=Repeat FadeOut2,#Speed#,20
FadeOut2=[!SetVariable Alpha2 "(Clamp(#Alpha2#-5,0,255))"]#Action#
DynamicVariables=1

[MeasureStart]
Measure=Calc
Formula=#Start#
IfCondition=(#Start#=1)
IfTrueAction=[!WriteKeyValue Variables Start "0"][!DisableMeasure "#CURRENTSECTION#"]
UpdateDivider=-1

[MeasureFileViewParent]
Measure=Plugin
Plugin=FileView
Path=#CurrentPath#Unsplash\
UpdateDivider=5
DynamicVariables=1

[MeasureFileCount]
Measure=Plugin
Plugin=FileView
Path=[MeasureFileViewParent]
Type=FileCount

[MeasureCount]
Measure=Calc
Formula=MeasureFileCount + 1
RegExpSubstitute=1
Substitute="^(.)$":"0\1"

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Parameter=Copy "[Webparser]" "#Path#\Unsplash[MeasureCount].jpg"
State=Hide
DynamicVariables=1

[WebParser]
Measure=Plugin
Plugin=WebParser
URL=https://source.unsplash.com/random/#SCREENAREAWIDTH#x#SCREENAREAHEIGHT#/
UpdateRate=-1
Download=1
DownloadFile=Unsplash.jpg
FinishAction=[!SetOption Webparser FinishAction """[!SetWallpaper "DownloadFile\Unsplash.jpg"]"""]

[Background]
Meter=Shape
Shape=Rectangle 0,0,(160*#Scale#),(45*#Scale#),(10*#Scale#) | StrokeWidth 1 | StrokeColor 255,255,255,0 | Fill LinearGradient Gradient
Gradient=180 | 255,255,255,0 ; 0.1 | 255,255,255,#Alpha2# ; 1
MouseOverAction=[!CommandMeasure MeasureFader "Stop 2"][!CommandMeasure MeasureFader "Execute 1"][!CommandMeasure MeasureFader "Stop 4"][!CommandMeasure MeasureFader "Execute 3"]
MouseLeaveAction=[!CommandMeasure MeasureFader "Stop 1"][!CommandMeasure MeasureFader "Execute 2"][!CommandMeasure MeasureFader "Stop 3"][!CommandMeasure MeasureFader "Execute 4"]
MiddleMouseDownAction=["#SKINSPATH#\UnsplashForRainmeter\Unsplash"]
;MiddleMouseDownAction=["#Path#"]
MouseActionCursor=0
DynamicVariables=1

[Unsplash]
Meter=String
Text=UnSplash
FontFace=Gilroy ExtraBold
;Quicksand
;Gilroy ExtraBold
;HelveticaNeueLT Com 75 Bd
FontSize=(14*#Scale#)
X=(15*#Scale#)
Y=(23*#Scale#)
StringStyle=Normal
StringAlign=LeftCenter
AntiAlias=1
FontColor=255,255,255,#Alpha1#
LeftMouseUpAction=[!CommandMeasure WebParser Update][PLAY #@#Sounds\Elevator Ding.wav][!Redraw]
DynamicVariables=1

[Next]
Meter=Image
ImageName=#@#Images/Next.png
ImageRotate=90
X=(30*#Scale#)R
Y=(13*#Scale#)
W=(20*#Scale#)
LeftMouseUpAction=[!CommandMeasure "MeasureRun" "Run"][!CommandMeasure MeasureFileViewParent "Update"][PLAY #@#Sounds\Elevator Ding.wav]
DynamicVariables=1
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: Wallpaper Changer

Post by zivallh »

I tried your code, the downloaded pictures started from 02 and once you reach 08 it keeps overwriting on the 08 picture and even doesn't run the file explorer
User avatar
tass_co
Posts: 511
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Wallpaper Changer

Post by tass_co »

zivallh wrote: August 28th, 2022, 1:20 pm I tried your code, the downloaded pictures started from 02 and once you reach 08 it keeps overwriting on the 08 picture and even doesn't run the file explorer
You must have something wrong.
Because I tried code and I have not encountered such problems as you said.
eclectic-tech code works fine.
If you delete the downloaded wallpapers and unload and load the skin, I believe your problem will be fixed :thumbup:
I don't know where i going from here, but i promise it won't be boring... :great: