If you don't mind installing PS module FP.SetWallpaper , here is a simple approach:
In Powershell:If the above does the desired effect for you then implement with something like the following .ini:And this would be the SwitchWallpaper.lua script :
In Powershell:
Code:
Install-Module -Name FP.SetWallpaper# Print monitorsGet-Monitor# 3 monitors and I wanted to set wallpaper only on 3rd so it was last in the listGet-Monitor | Select-Object -Last 1 | Set-WallPaper -Path C:\MyGallery\img_01.jpg
Code:
[Rainmeter]BackgroundMode=0Update=10000OnRefreshAction=[!CommandMeasure MeasureScript "Initialize()"][Variables]height=500myWidth=(#height#*2 + 10)myHeight=(#height#*2 + 10)[MeasureScript]Measure=ScriptScriptFile="#CURRENTPATH#SwitchWallpaper.lua"[MeasureRunPowerShell]Measure=PluginPlugin=RunCommandProgram=powershell.exeParameter=-Command "Get-Monitor | Select-Object -Last 1 | Set-WallPaper -Path 'C:\MyGallery\img_01.jpg'"State=Hide; To work properly Rainmeter needs one meter , put whatever you want[MeterImage]Meter=ImageImageName=random.pngx=5y=5w=#myWidth#h=#myHeight#Greyscale=1
Code:
-- Initialize function, sets up the initial values and reads currentIndex from a filefunction Initialize() currentIndex = 1 -- Initialize the currentIndex to 1 imageCount = 10 -- Total number of images available -- Open the file 'currentIndex.txt' in read mode local file = io.open(SKIN:MakePathAbsolute("currentIndex.txt"), "r") if file then -- If the file exists, read the content and convert it to a number currentIndex = tonumber(file:read("*all")) file:close() -- Close the file after reading else -- If the file does not exist, set currentIndex to 1 currentIndex = 1 endend-- Update function, increments the currentIndex and updates the desktop background wallpaperfunction Update() -- Increment currentIndex and loop back to 1 if it exceeds imageCount currentIndex = (currentIndex % imageCount) + 1 -- Generate the new image path based on the updated currentIndex local newImagePath = SKIN:ReplaceVariables("#CURRENTPATH#img_" .. string.format("%02d", currentIndex) .. ".jpg") SetDesktopBackground(newImagePath) -- Set the new desktop background -- Open the file 'currentIndex.txt' in write mode to save the updated currentIndex local file = io.open(SKIN:MakePathAbsolute("currentIndex.txt"), "w") file:write(tostring(currentIndex)) -- Write the currentIndex to the file file:close() -- Close the file after writingend-- Function to set the desktop background using a PowerShell commandfunction SetDesktopBackground(imagePath) -- Prepare the PowerShell command to set the desktop background local psCommand = 'Get-Monitor | Select-Object -Last 1 | Set-WallPaper -Path \'' .. imagePath .. '\'' -- Execute the PowerShell command using SKIN:Bang SKIN:Bang('!SetOption', 'MeasureRunPowerShell', 'Parameter', '-Command "' .. psCommand .. '"') SKIN:Bang('!CommandMeasure', 'MeasureRunPowerShell', 'Run')end
Statistics: Posted by rainmeister — Yesterday, 3:18 pm