Travel the World from Your Desktop: How to Use Python to Switch Up Your Wallpaper

Are you tired of staring at the same old desktop background on your Windows laptop every day? Do you have a collection of beautiful travel pictures that you’d love to see on your screen instead? If you answered yes to both of these questions, then you’re in luck! In this post, I’ll show you how to create a Python script that changes your desktop background every 15 minutes using your favorite travel photos. I have done the same for my office laptop.

First, create a new folder on your laptop called “pics” and add your favorite travel pictures to it. You can use images from your own travels or download high-quality images from website of your choice.

Next, let’s create the Python script that will change your desktop background. Open up your favorite text editor and create a new file called “”. Then, copy and paste the following code:

import ctypes
import os
from random import choice
import sched
import time

event_schedule = sched.scheduler(time.time, time.sleep)


FILES = [os.path.join(FOLDER, f) for f in os.listdir(FOLDER)]

def change_wallpaper():
    event_schedule.enter(choice([13,23,7,11,5])*60, 1, change_wallpaper, ())

if __name__ == "__main__":
    event_schedule.enter(10, 1, change_wallpaper, ())

Make sure to replace “FOLDER” with your actual path of your images.

This code uses the “ctypes” module to call the “SystemParametersInfoW” function from the Windows API, which changes the desktop background to a random image from the “pics” folder. The script then waits for random minutes before changing the background again.

Save the file and make sure it is in a directory that you can easily access. Now, let’s schedule the script to run automatically every time you start your laptop.

Open up the Windows Task Scheduler by searching for it in the Start menu. Click on “Create Basic Task” and follow the prompts to set up a new task.

When prompted to choose a program/script, browse to the location of your “” file and select it. Set the trigger to “At Startup” and click “Finish” to complete the setup.

Now, every time you start your laptop, your Python script will automatically run in the background and change your desktop background every 15 minutes.

In conclusion, with just a few lines of Python code and the Windows Task Scheduler, you can turn your boring desktop background into a slideshow of your favorite travel photos. Give it a try and let me know how it goes!

Related More


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s