I use the solution provided in this post to change the Windows desktop wallpaper from Python
In particular here is the code sample
import ctypes
import os
image_file = "myimage.jpg"
print("Setting the wallpaper")
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, os.path.abspath(image_file) , 0)
The problem is that the change is non persistent, in the sense that the desktop wallpaper gets reset whenever I restart my PC. How can I persistently change the Windows desktop wallpaper from Python?
I use python 3.5
You need to call it like this
print("Setting the wallpaper")
SPI_SETDESKWALLPAPER = 20
SPIF_UPDATEINIFILE = 1
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, os.path.abspath(image_file) , SPIF_UPDATEINIFILE)
Also have a look at the related documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With