当前位置: 代码迷 >> 综合 >> python 切换壁纸
  详细解决方案

python 切换壁纸

热度:78   发布时间:2024-03-08 00:26:17.0

首先下载包:pywin32

然后复制以下代码进行调用即可

import win32api, win32gui, win32condef UpdateWallpaper(imgpath):regKey = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,"Control Panel\\Desktop",0,win32con.KEY_SET_VALUE)win32api.RegSetValueEx(regKey,"WallpaperStyle", 0, win32con.REG_SZ, "2")win32api.RegSetValueEx(regKey, "TileWallpaper", 0, win32con.REG_SZ, "0")win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER,imgpath, win32con.SPIF_SENDWININICHANGE)

记录一下,方便查找

 

  相关解决方案