Global Const $DESKTOP_SWITCHDESKTOP = 0x0100
Func _IsWorkstationLocked()
Local $Result = False
$hDesktop = DllCall('user32.dll', 'hwnd', 'OpenDesktop', 'str', 'Default', 'int', 0, 'int', 0, 'int', $DESKTOP_SWITCHDESKTOP)
If Not @error Then
$Result = DllCall('user32.dll', 'int', 'SwitchDesktop', 'hwnd', $hDesktop[0])
$Result = Not $Result[0]
DllCall('user32.dll', 'int', 'CloseDesktop', 'hwnd', $hDesktop[0])
EndIf
Return $Result
EndFunc ;==>_IsWorkstationLocked
While 1
If Not _IsWorkstationLocked() Then
Consolewrite('Экран разблокирован')
;Sleep(2000)
else
Consolewrite('Экран заблокирован')
EndIf
Sleep(2000)
WEnd