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 ?
LVL 45
AndyAinscowFreelance programmer / ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantAuthor Commented:
context menu
0
Joe Winograd, Fellow&MVEDeveloperCommented:
Hi Andy,

Check out this thread:

http://social.technet.microsoft.com/Forums/windows/en-US/42a196d3-a3b0-47d9-b5bb-009324aded93/next-desktop-background-shortcut-key?forum=w7itproui

I'm a huge fan of AutoHotkey, an excellent (free!) programming/scripting/keyboard macro language, so that's the solution I would use, although you may prefer one of the others. If you do like the AutoHotkey approach, note that there have been several forks of the original language and my preferred one now is AutoHotkey_L. It comes with a compiler that turns the AHK source code (plain text) into a stand-alone/no-install executable (an EXE file).

There is good documentation:
http://l.autohotkey.net/docs/

...including an alphabetical command and function index:
http://l.autohotkey.net/docs/commands/index.htm

...a decent tutorial:
http://l.autohotkey.net/docs/Tutorial.htm

...and an active user forum:
http://www.autohotkey.com/board/

Regards, Joe
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
From the first link:
set WshShell = WScript.CreateObject("WScript.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.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Jacques Bourgeois (James Burger)PresidentCommented:
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)

Open in new window

0
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
@James - thanks but that isn't quite what I was asking for.  (Maybe it is something similar)
0
Joe Winograd, Fellow&MVEDeveloperCommented:
You're welcome. That VBS script is a clean, simple solution. Regards, Joe
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.