AndyAinscow
asked on
Changing windows 7 wallpaper via an app or batch file
I've got a collection of pictures that I use for the wallpaper on a windows desktop. It is set to move through the collection randomly at 30 minute intervals.
Occasionally I would like to change the wallpaper (as if the 30 minute interval had elapsed) at that instant. I can go to the desktop, right click then in the context menu select 'Next esktop background'. Now I sometimes find that a bit of work and would like to have an app/bat file on the desktop that would perform the same action.
What command / windows API is required to perform the same action as that context menu command ?
Occasionally I would like to change the wallpaper (as if the 30 minute interval had elapsed) at that instant. I can go to the desktop, right click then in the context menu select 'Next esktop background'. Now I sometimes find that a bit of work and would like to have an app/bat file on the desktop that would perform the same action.
What command / windows API is required to perform the same action as that context menu command ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
From the first link:
set WshShell = WScript.CreateObject("WScr ipt.Shell" )
WshShell.SendKeys("^ ")
WshShell.SendKeys("+{F10}" )
WshShell.SendKeys("n")
saved as a vbs file on the desktop. Double click and it does the job.
Excellent, thanks.
set WshShell = WScript.CreateObject("WScr
WshShell.SendKeys("^ ")
WshShell.SendKeys("+{F10}"
WshShell.SendKeys("n")
saved as a vbs file on the desktop. Double click and it does the job.
Excellent, thanks.
The API to call is SystemParametersInfo, with SPI_SETDESKWALLPAPER (20) as the first parameter. Here is sample code in VB:
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uiAction As Integer, ByVal uiParam As Integer, ByVal pvParam As String, ByVal fWinIni As Integer) As Boolean
Const SPIF_UPDATEINIFILE As Short = 1
Const SPI_SETDESKWALLPAPER As Short = 20
Const SPIF_SENDWININICHANGE As Short = 2
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\Images\MyPicture.jpg", SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
ASKER
@James - thanks but that isn't quite what I was asking for. (Maybe it is something similar)
You're welcome. That VBS script is a clean, simple solution. Regards, Joe
ASKER