Is there a way to auto-check if the current user locked his PC? (usually activated by Win+L). One hacky method I see is somehow catch all key combinations, but then the question is how to know that the user has returned? Maybe there is some flag that can be accessed through python or windows terminal? EDIT: I tried the code from here: Detect when computer is unlocked Windows It detects when screen is locked, but not when it's unlocked, it continues to write "Screen is still locked" indefinitely. So what can be the problem? I have Python 3.4, 64-bit Win7. EDIT2: Actually the result is always 0 for me, even without any locking, so in fact it doesn't detect anything. import ctypes user32 = ctypes.windll.User32 OpenDesktop = user32.OpenDesktopA SwitchDesktop = user32.SwitchDesktop DESKTOP_SWITCHDESKTOP = 0x0100 hDesktop = OpenDesktop ("default", 0, False, DESKTOP_SWITCHDESKTOP) result = SwitchDesktop (hDesktop) print(result) Continue reading...