使用python持久更改Windows桌面墙纸

2024-04-29 08:21:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用thispost中提供的解决方案从Python更改Windows桌面墙纸

这里是代码示例

import ctypes
import os
image_file = "myimage.jpg"
print("Setting the wallpaper")
SPI_SETDESKWALLPAPER = 20 
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0,  os.path.abspath(image_file) , 0)

问题是这种改变是非持久性的,从某种意义上说,每当我重新启动电脑时,桌面墙纸都会被重置。我如何从Python持续更改Windows桌面墙纸?在

我使用python3.5


Tags: 代码imageimportspi示例oswindows解决方案