I've been trying to make myself some code that will change the background. I've done all the extra parts of my project, everything works fine, but I just can't get the desktop background changing function to work. This is the part of the code that's giving me headaches:
import ctypes
ctypes.windll.user64.SystemParametersInfoW(20, 0, ImagePath, 0)
I've seen many people have this error, but I've looked all over this site and tried many different things, and now I'm lost as to what is the issue, or what else I could do. I've checked and there's no issue with my image path, such that if I add the following lines to my code,
from PIL import Image
im = Image.open(ImagePath)
im.show()
the image opens just fine. But the background never actually changes, not even a black screen. Other things I tried include changing SystemParametersInfoW
to SystemParametersInfoA
, removing my second monitor, disabling Windows Aero, using jpg and png images, used different variations of the image path (with forward or backward slashes)... And when I gave the code to a friend of mine, he tested it on his PC and it worked flawlessly, and neither of us had any idea what the issue was.
A couple of things worth mentioning -- printing ctypes.windll.user64.SystemParametersInfoW(20, 0, ImagePath, 0)
returns 0, I'm using Win 7, I tried both Python 3.8 and 3.7.
Can anybody shed some light as to what I've been doing wrong?