0

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?

  • 1
    `he tested it on his PC and it worked flawlessly` - so what are your friend's specs? You only listed yours. The basic thing would be to compare your systems and how you both run the script - inside IDE or not? with what user privileges, or maybe even as admin? etc – h4z3 Dec 17 '19 at 14:46
  • As far as I know, I installed Python the same way he did -- although I am planning to reinstall Python all over again soon. Other than that, the only difference I can think of is that he uses Win10 whereas I use Win7, but we did everything else the exact same way (as far as I know, at least). I also tried running the compiler as admin, and nothing changed. @h4z3 – Lucas Menezes Dec 17 '19 at 17:55

0 Answers0