How can I check whether a Windows OS workstation is locked? (e.g. Win+L or choosing the lock option after Ctrl+Alt+Del.)
I want something like ctypes.windll.us
ctypes.windll.us
You can get the window on top, when the session is locked, the function return 0.
import ctypes user32 = ctypes.windll.User32 def isLocked(): return user32.GetForegroundWindow() == 0