'Python - change wallpaper

I'm trying to change my wallpaper (windows 11) using python (3.10.4) PERMANENTLY, on all virtual desktops, on all monitors without me even knowing it.

I found this solution:

import ctypes
ctypes.windll.user32.SystemParametersInfoW(0x14, 0, "C:/Users/42077/Desktop/xxx.jpeg", 0x2)

and it's working, it change my wallpaper on all monitors... BUT, when I switch between virtual desktops (shift+win+arrows), windows just reset the wallpaper to the one that was there before and I can't find any other solution. Everyone says this works.

I also tried close all virtual desktops, keep only 1, change wallpaper using this and then create new virtual desktops... still the same problem. (but i dont want to close all desktops and create new ones to be honest - because it would bother me)

Do I need to change settings directly in windows or something?

I also tried removing "TranscodedWallpaper" from AppData before/after changing the wallpaper + run it as administrato & also change it using bat file - same problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source