How can I change my desktop background with python?
I want to do it in both Windows and Linux.
Click on Personalization, which is fourth from the bottom on the list. 4. Click on Background. The background page will come up which allows you to preview your background picture and lets you choose from several photos or your own photos for your desktop background.
On Windows with python2.5 or higher, use ctypes to load user32.dll and call SystemParametersInfo()
with SPI_SETDESKWALLPAPER action.
For example:
import ctypes SPI_SETDESKWALLPAPER = 20 ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "image.jpg" , 0)
For Python3.5, SystemParametersInfoA doesn't work. Use SystemParametersInfoW.
import ctypes ctypes.windll.user32.SystemParametersInfoW(20, 0, "absolute path" , 0)
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