我正在嘗試製作一張圖像作爲我的桌面圖像。
我的圖片路徑:爲什麼我的桌面屏幕變黑?
#Image Path
import random,os
folder= r"C:\\Users\rkp10\AppData\Local\Google\Chrome\User Data\Default\Extensions\laookkfknpbbblfpciffpaejjkokdgca\0.91.6_0\backgrounds"
a=random.choice(os.listdir(folder))
print(a)
打開圖像:
#Opening the Image
from PIL import Image
file = folder+'\\'+a
Image.open(file).show()
使圖像作爲我的桌面圖像:
#Making the image as desktop image
import ctypes
image_path = file
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, image_path, 3)
現在的事情是圖像路徑被發現,它也會打開一個圖像。但不是將打開的圖像設置爲桌面圖像,而是將我的桌面圖像設爲黑色。
很好的瞭解,你找到了答案:) – ABcDexter