我一直試圖通過結合不同來源的代碼隨機化我的壁紙變化與python。我設法讓這樣的代碼:Wallpaperchanger python
import ctypes
import os
import random
drive = "C:/Users/UserName/Desktop/FolderofWallpaperFolders"
afolder = os.listdir(drive)
folder = drive+ "/" + random.choice(afolder)
aimage = os.listdir(folder)
image = random.choice(aimage)
image_path = os.path.join(drive, folder, image)
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0,image_path, 3)
但是當我運行它,它變成我的壁紙完全黑屏。 任何修改建議?
可能的重複[在ctypes中創建背景更換器,不工作](https://stackoverflow.com/questions/21715895/creating-a-background-changer-in-python-with-ctypes-not-工作) –
另一個重複:https://stackoverflow.com/questions/40574622/how-do-i-set-the-desktop-background-in-python-windows –