问题描述
我知道使用 ctypes.windll.user32.SystemParametersInfoW(20,pathToImage,3)
我可以更改墙纸图像并且通过将 pathToImage
设置为空字符串我实际上没有图像作为墙纸,因此我将看到 solid背景色。
我的问题是,如何改变纯色背景?
编辑 #1
进一步调查 Windows API。我发现 IDesktopWallpaper setbackgroundcolor() 方法听起来像是我需要的东西。但是,我不知道如何通过 python 或命令行调用/使用它。
解决方法
使用 IDesktopWallpaper(来自 winuser.h
标头)比使用 SetSysColors 更简单。
在 Python 中,代码如下所示:
import ctypes
from ctypes.wintypes import RGB
from ctypes import byref,c_int
def changeSystemColor(color)
ctypes.windll.user32.SetSysColors(1,byref(c_int(1)),byref(c_int(color)))
if __name__ == '__main__':
color = RGB(255,0) # red
changeColor(color)
如您的帖子所述,您可以执行 ctypes.windll.user32.SystemParametersInfoW(20,"",3)
删除墙纸图像,暴露您可以使用 ctypes.windll.user32.SetSysColors
设置的纯色背景。