A story about making a script that changes the Windows wallpaper according to the time.
point:
ctypes.windll.user32.SystemParametersInfoW
.import ctypes
import os
import datetime
import time
image_dir = r'D:\wallpaper'
current_image_name = None
while True:
now = datetime.datetime.now()
if now.hour < 6 or 19 <= now.hour:
new_image_name = 'star.png'
elif 17 <= now.hour:
new_image_name = 'sunset.jpeg'
else:
new_image_name = 'daytime.jpeg'
if new_image_name != current_image_name:
abs_file_name = os.path.join(image_dir , new_image_name)
ctypes.windll.user32.SystemParametersInfoW(20, 0, abs_file_name, 0)
current_image_name = new_image_name
time.sleep(1) # check every 1 sec
Since it flickers when switching, check for changes and execute SystemParametersInfoW
only when there is a change.
It may be interesting to change it every season. It would be nice if the wallpaper looks like a window and you can feel the time and seasons.