from win32api import GetKeyState from win32con import VK_CAPITAL if GetKeyState(VK_CAPITAL) == 1: print("Caps Lock is on") else: print("Caps Lock is off")