3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PythonでWindowsの壁紙を動的に変更させる方法

Posted at

PythonからWindowsのデスクトップ壁紙を変更できます。
画像を自動生成して天気用法の表示的なものが出来そうです。
ChatGPTに投げて、なんか出来たため書いときます。

import ctypes
import os
import time

# 壁紙を変更する関数
def change_wallpaper(image_path):
    if os.path.isfile(image_path):
        ctypes.windll.user32.SystemParametersInfoW(20, 0, image_path, 3)
    else:
        print("指定されたパスに画像が存在しません。")

# 壁紙リスト(画像パス))パスを書き換えてください。
wallpapers = [r"C:\Users\User\Desktop\a.png",r"C:\Users\User\Desktop\b.png"]

# 壁紙を変える
while True:
    change_wallpaper(wallpapers[0])
    time.sleep(0.1)
    change_wallpaper(wallpapers[1])
    time.sleep(0.1)
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?