Does anyone know a way to change the Windows Desktop Wallpaper with python so that the change is permanent? I have found this code
import ctypes
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "myimage.jpg" , 0)
This code works, but once you log off and log on again, the background is back to the original image. I would prefer a solution that does not require any registry edit, and I would like something that works with Windows XP and 7 if it is possible.
fWinIni
, "specifies whether the user profile is to be updated". The flags areSPIF_UPDATEINIFILE == 1
andSPIF_SENDCHANGE == 2
. The latter broadcasts aWM_SETTINGCHANGE
message. Try usingfWinIni == 3
. – Medora