Reputation: 97
I'm working on a small project for myself and I hit a wall. I need to change the desktop background on Windows 10 64-bit. I have attempted to use the script below to change the background based on a local image. The code executes without errors, however the desktop just turns black. I double checked and my image is at c:\CuratedWallpaper\Mario.bmp
so that is not the issue.
import ctypes
directory = "c:\CuratedWallpaper"
imagePath = directory + "\Mario.bmp"
def changeBG(imagePath):
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, imagePath , 0)
return;
changeBG(imagePath)
Upvotes: 4
Views: 8900
Reputation: 111
I use SystemParametersInfoW instead of SystemParametersInfoA like this:
ctypes.windll.user32.SystemParametersInfoW(20, 0, path, 3)
It is a matter of ANSI vs UNICODE path string.
It works for me in windows 10.
Upvotes: 7