【问题标题】:Change Windows 10 Background Solid Color in Python在 Python 中更改 Windows 10 背景纯色
【发布时间】:2021-05-27 01:30:59
【问题描述】:

我知道使用ctypes.windll.user32.SystemParametersInfoW(20, 0, pathToImage, 3) 我可以更改墙纸图像,并且通过将pathToImage 设置为空字符串,我实际上将没有图像作为墙纸,因此我将看到纯色背景色 em>。

我的问题是,如何改变纯色背景色


编辑#1

进一步研究 Windows API。我发现IDesktopWallpaper setbackgroundcolor() 方法听起来像是我需要的东西。但是,我不知道如何通过 python 或命令行调用/使用它。

【问题讨论】:

    标签: python windows colors desktop wallpaper


    【解决方案1】:

    使用SetSysColors(来自winuser.h 标头)更简单,而不是使用IDesktopWallpaper

    在 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, 0) # red
        changeColor(color)
    

    如您的帖子中所述,您可以使用ctypes.windll.user32.SystemParametersInfoW(20, 0, "", 3) 删除壁纸图片,露出您可以使用ctypes.windll.user32.SetSysColors 设置的纯色背景。

    【讨论】:

      猜你喜欢
      • 2019-05-21
      • 1970-01-01
      • 2014-03-26
      • 1970-01-01
      • 1970-01-01
      • 2016-09-10
      • 1970-01-01
      • 2022-11-22
      相关资源
      最近更新 更多