sublimnl Posted June 21, 2007 Share Posted June 21, 2007 Like the title says, I need to determine whether the workstation is locked and then wait to proceed until it is unlocked. Anyone know of a way to do it? While 1 If <somehow-check-if-computer-is-locked> Then Sleep(250) Else ExitLoop EndIf WEnd Link to comment Share on other sites More sharing options...
DW1 Posted June 21, 2007 Share Posted June 21, 2007 this could cause a few false positives I think, but it worked for me. While 1 Sleep(1000) $title = WinGetTitle( "" ) $text = WinGetText( "" ) If StringInStr ( $text, "Program Manager" ) <> 0 and $title = "" Then FileWrite( "test.log", @HOUR & ":" & @MIN & ":" & @SEC & " - " & "workstation locked" & @CRLF) EndIf WEnd additionally, if your setup is triggering false positives with the test script above, try including the AutoItSetOption("WinDetectHiddenText",1) option with flag set to 1 (read hidden text) and include more information to test with the StringInStr function. Hope this helps AutoIt3 Online Help Link to comment Share on other sites More sharing options...
sublimnl Posted June 21, 2007 Author Share Posted June 21, 2007 Thanks for that. I will give it a shot! Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 27, 2007 Moderators Share Posted July 27, 2007 Original code by tonedeaf.HotKeySet("{ESC}", "_Exit") $DESKTOP_SWITCHDESKTOP = 0x100 While 1 If _IsLocked() Then ConsoleWrite("Workstation is locked." & @CR) Else ConsoleWrite("Workstation not locked." & @CR) EndIf Sleep(1000) WEnd Func _IsLocked() $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP) $ret = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0]) DllCall("User32.dll", "int", "CloseDesktop", "int", $ret[0]) If $ret[0] Then Return SetError(0, 0, 0) Else Return SetError(0, 0, 1) EndIf EndFunc ;==>_IsLocked Func _Exit() Exit EndFunc ;==>_Exit Link to comment Share on other sites More sharing options...
Furek86 Posted November 25, 2010 Share Posted November 25, 2010 (edited) Can the above code be modified to also detect if a remote PC is locked or not? Is there a way to do that? Edited November 25, 2010 by Furek86 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now