Skip to content

Instantly share code, notes, and snippets.

@SMUsamaShah
Created September 18, 2023 11:36
Show Gist options
  • Select an option

  • Save SMUsamaShah/49fe324c47c4c26cee9dbff626437cb7 to your computer and use it in GitHub Desktop.

Select an option

Save SMUsamaShah/49fe324c47c4c26cee9dbff626437cb7 to your computer and use it in GitHub Desktop.
AutoHotkeyScript to Delete current wallpaper and move to Next desktop background
; Get path of current wallpaper file from registry
RegRead, TranscodedImageCache, HKEY_CURRENT_USER, Control Panel\Desktop, TranscodedImageCache
WallpaperPath := % BinaryToText(TranscodedImageCache)
;MsgBox, % WallpaperPath
; Delte the actual wallpaper image file
FileDelete, % WallpaperPath
; Select next background, same as desktop right click + Next desktop background
next_bg()
BinaryToText(binaryData) {
stringData := ""
Loop, % StrLen(binaryData)
{
if (A_Index <= 24)
continue
string := ""
hex := SubStr(binaryData, 2*A_Index - 1, 2)
;If (hex != "00")
stringData .= Chr("0x" . hex)
}
return stringData
}
; source: https://www.autohotkey.com/boards/viewtopic.php?t=34436
next_bg() {
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)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment