I got the function "LockWorkStation" when searching for a solution of how to lock the system:
[MSDN:LockWorkStation]
And it says:
Quote:
There is no function you can call to determine whether the workstation is locked. To verify whether it is worth attempting to update your user interface, you can test whether or not your window is visible.
So, I wrote a GUI script for testing, but not works:
Code:
; Press [F12] to lock your system, waits about 3+ seconds and unlock it.
; Then press [F10] to check if system has ever been locked (hope so).
Gui, Show, w400 h300, Test
SysLocked = Unlocked
Return
GuiClose:
ExitApp
F12::
Result := DllCall("LockWorkStation", "str", "User32.dll")
Goto, TestWin
Return
TestWin:
Sleep, 3000
WinGet, Style, Style, Test ahk_class AutoHotkeyGUI
If !(Style & 0x10000000) ; 0x10000000 is WS_VISIBLE
SysLocked = Locked
Return
F10::MsgBox %SysLocked%
#x::ExitApp