samedi 14 octobre 2023

How to get color settings of system UI (color theme) in Windows 10 with Python?

I'm trying to get some color settings in UI of Windows 10, e.g. colors of window title bar when windows are activated/inactivated, the edge color of window. Or to be more simple, I'm searching for a function like getSysColor() in winuser.h(Documentation) in Windows 10.

What I mean by "colors of window title bar when windows are activated" under "color settings in UI of Windows 10". (red circle)

Here's something I've tried:

  1. getSysColor(nIndex) in winuser.h:

    This function cannot work well under Windows 10, for some keys(nIndex) are not supported according to the (Documentation) . For example, if I ask for the colors of activated window title bar with ctypes.windll.user32.GetSysColor(2) in Python, it will return the color of ##99B4D1, which is maybe the color under Windows 7, rather than the ##0078D7 in Windows 10. But I don't want a color set of Windows 7.

  2. DwmGetColorizationColor() in dwmapi.h:

    Some suggest that this function may retrieve the color of title bar. But I can only get a strange yellow (##F8FFA9) with ctypes.windll.dwmapi.DwmGetColorizationColor(), which is definetly not what I want. Meanwhile this function can only offer color of title bar, rather than all the color used in Windows UI.

Aucun commentaire:

Enregistrer un commentaire