문제

Just as the question asks, I know this is possible on Linux, but I couldn't find anything recent for Windows. Is it even possible?

도움이 되었습니까?

해결책

You can use ctypes to load user32.dll and then call GetKeyState with nVirtKey = VK_CAPITAL (0x14)

def get_capslock_state():
    import ctypes
    hllDll = ctypes.WinDLL ("User32.dll")
    VK_CAPITAL = 0x14
    return hllDll.GetKeyState(VK_CAPITAL)

다른 팁

Install pywin32 for Python 3.x

Here is the example for checking capslock state.

from win32api import GetKeyState 
from win32con import VK_CAPITAL 
GetKeyState(VK_CAPITAL)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top