Skip to content

Instantly share code, notes, and snippets.

@raveren
Last active January 17, 2024 18:27
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save raveren/ab475336cc69879a378b to your computer and use it in GitHub Desktop.
Save raveren/ab475336cc69879a378b to your computer and use it in GitHub Desktop.
Open current wallpaper in windows8
Set Shell = CreateObject("WScript.Shell")
' change to TranscodedImageCache_001 for second monitor and so on
openWallpaper("HKCU\Control Panel\Desktop\TranscodedImageCache_000")
function openWallpaper(regKey)
arr = Shell.RegRead(regKey)
a=arr
fullPath = ""
consequtiveZeroes = 0
For I = 24 To Ubound(arr)
if consequtiveZeroes > 1 then
exit for
end if
a(I) = Cint(arr(I))
if a(I) > 1 then
fullPath = fullPath & Chr(a(I))
consequtiveZeroes = 0
else
consequtiveZeroes = consequtiveZeroes + 1
end if
Next
Shell.run Chr(34) & fullPath & Chr(34)
end function
Wscript.Quit
@raveren
Copy link
Author

raveren commented Aug 1, 2022

okay, makes sense, thank you!

@crius-al
Copy link

crius-al commented Oct 1, 2022

Please feel free to use my slightly different wallpaper script. This one opens the folder and highlights the image.

Const HKCU = &H80000001 'HKEY_CURRENT_USER

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
            & ".\root\default:StdRegProv")

sKeyPath = "Control Panel\Desktop\"
sValueName = "TranscodedImageCache"
oReg.GetBinaryValue HKCU, sKeyPath, sValueName, sValue

sContents = ""

For i = 24 To UBound(sValue)
  if sValue(i) = 0 and sValue(i+1) = 0 then exit for
  sByte = sValue(i)+sValue(i+1)*256
  sContents = sContents & ChrW(sByte)
  i=i+1
next
CreateObject("Wscript.Shell").Run "explorer.exe /select, """ & sContents & """"

@MoneyAllDay
Copy link

Please feel free to use my slightly different wallpaper script. This one opens the folder and highlights the image.

What are the odds this was exactly what i was looking for and you just posted it 19 days ago?

Thank you!

@crius-al
Copy link

Please feel free to use my slightly different wallpaper script. This one opens the folder and highlights the image.

What are the odds this was exactly what i was looking for and you just posted it 19 days ago?

Thank you!

The odds are 100%. :)

@raveren
Copy link
Author

raveren commented Jan 17, 2024

Same line of thought reused in this Autohotkey script:

https://gist.github.com/raveren/bac5196d2063665d2154

look for WIN+W

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment