What’s up guys? Got a sweet and short tutorial for you today!
Before we begin, I want to clarify this tutorial is for Windows 10. I’m pretty sure it should work for other Windows version as well. I will probably make a Linux version for it soon too, so watch out for it! If you’re interested in it for a different operating system, leave a comment below.
Also, if you just want the script and don’t care about the article, head all the way down to the end of the post where you will find a download for either the Python 2.7 version or Python 3 scripts. Please watch the video though, so you know the instructions to get the script working (its easy!).
Yesterday I was looking for a way to automatically change the background / wallpaper of both my monitors using a Python script (every X seconds).
Although I was able to find a few sources to change the background, it would change the background for both of my monitors at once.
I then ran into this stackoverflow post, where a user replied suggesting merging two images into one and then setting the background as a tiled image using Win32 API functions – thank you fine sir.
I decided this could be a fun little challenge and set out to do it. 😉
Like I just mentioned we’re gonna need the following libraries:
Using PIP you can just run the following commands to install them:
- python -m pip install pywin32
- python -m pip install pillow
It simply makes the process a whole lot easier!
You can click above or here to download the code (which includes both the Python 2.X version and Python 3 version). You’ll find the Python 3 has a ‘3’ at the end of the script’s filename.
Please note you will need to change the directory to where the background are located and inside that directory there should be two folders named “1920×1080” and “1920×1200” or you can simply alter the script and change the names to whatever you like.
If you understand a little bit of Python it should all be very clear from watching the video posted, but in any case, leave a comment below and I’ll do my best to help you out! Additionally, you can check the references below to understand more about certain details.
Here I’ll link some of the posts I mentioned in the video that helped me ultimately get the task done – couldn’t have done it without y’all!
- PyWin32: How to set the desktop background on Windows
- Combine several images horizontally with Python
- Different wallpaper for multi-monitor setups in Windows
That’s it for today, hope you guys enjoyed and see you next time!