Red de conocimientos turísticos - Información de alquiler - [Python Baiwen] Utilice Python para cambiar el fondo del escritorio

[Python Baiwen] Utilice Python para cambiar el fondo del escritorio

Ruta="D:\Mis documentos\Mis imágenes\Fondo de pantalla" #Directorio de fondos de pantalla

nueva ruta = ruta del SO . getenv(" appdata ")," Microsoft\Wallpaper1.bmp ".

getwnd = FindWindow(" Shell _ tray wnd ", Ninguno)

screen_height 0 = GetSystemMetrics(win32 con. SM_CYSCREEN)

screen_ height = screen_ height 0-GetClientRect(Getwnd)[3]

pantalla _ ancho = GetSystemMetrics(win32 con. SM_CXSCREEN)

def cambiar _wallpaper():

filelist=os .listdir(ruta)

ran pic = lista de archivos[random . randint(0, len(filelist)-1)]

filefullpath="%s \%s" % ( ruta, ranpic)

im=Image.open(filefullpath)

if im.size[0]! =ancho_pantalla o im.size[1]! =screen_height0:return

im.save(newpath, "BMP")

windll usuario 32 parámetros del sistema sinfoa(20, 0, newpath, 0)

<. p>def wallpaper_thread():

Y 1:

cambiar fondo de pantalla()

tiempo de suspensión = aleatorio . p>

Imprimir tiempo de sueño

Tiempo de sueño

thread.start_new_thread(wallpaper_thread, ())