0

I have set slideshow as my Windows 10 background. I can right click on the desktop and select Next desktop background to change it to the next image. Is there any way to do this via cmd or powershell considering my current Shuffle setting in slideshow (on or off)? I found that this item is located here in regedit and its data

HKEY_CLASSES_ROOT\DesktopBackground\shellex\ContextMenuHandlers\DesktopSlideshow

but couldn't find any way to run it.

I need to run this by command

3 Answers3

2

It's possible to automate "Next desktop background" using the free AutoHotkey.

The following script will change to the next image in the slideshow when pressing Ctrl+F10:

^F10::
try if ((pDesktopWallpaper := ComObjCreate("{C2CF3110-460E-4fc1-B9D0-8A1C0C9CC4BD}", "{B92B56A9-8B55-4E14-9A89-0199BBB6F93B}"))) {
    DllCall(NumGet(NumGet(pDesktopWallpaper+0)+16*A_PtrSize), "Ptr", pDesktopWallpaper, "Ptr", 0, "UInt", 0) ; IDesktopWallpaper::AdvanceSlideshow - https://msdn.microsoft.com/en-us/library/windows/desktop/hh706947(v=vs.85).aspx
    ObjRelease(pDesktopWallpaper)
}

After installing AutoHotKey, put the above text in a .ahk file and double-click it to test. You may stop the script by right-click on the green H icon in the traybar and choosing Exit. To have it run on login, place it in the Startup group at
C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

Useful AutoHotkey documentation:

Reference : A subroutine to switch to the next background (Windows 10).

harrymc
  • 498,455
0

Update to harrymc's answer above for anyone else struggling to get this working in AutoHotKeyV2 this is the code you you need :-

#Requires AutoHotkey v2.0
try if ((pDesktopWallpaper := ComObject("{C2CF3110-460E-4fc1-B9D0-8A1C0C9CC4BD}", "{B92B56A9-8B55-4E14-9A89-0199BBB6F93B}"))) {
        ComCall(16, pDesktopWallpaper, "Ptr", 0, "UInt", 0) 
        ObjRelease(pDesktopWallpaper)
}
Kev
  • 111
0

And my update to KEV's answer:

I'm running Version 2.0.11 of AutoHotKey

When I ran Kev's code, AHK threw an error on "ObjRelease(pDesktopWallpaper)", but the actual wallpaper-change had already taken place, so I just commented out that part and it works like a charm for me now! Thanks a lot, Harrymc and Kev !!

/* Ctrl-F10 = Invoke "Next Desktop Background" from 'anywhere' */
^F10::try if ((pDesktopWallpaper := ComObject("{C2CF3110-460E-4fc1-B9D0-8A1C0C9CC4BD}", "{B92B56A9-8B55-4E14-9A89-0199BBB6F93B}"))) {
        ComCall(16, pDesktopWallpaper, "Ptr", 0, "UInt", 0)
}