Sign in to follow this  
Followers 0
RogFleming

Windows system idle workstation lock

5 posts in this topic

I know about GPO and such, I just wanted something different to use to lock the computer.

I have experanced issues that after running it, that after a few passes the variables no longer increase in value. Even if I start the process again, is this normal for the GO feature of the Editor? Seems the only to get the GO to work again is to reboot my computer. Does any one have any ideas?

I got the IsPressedEx_UDF.au3 from the forums.....

#Include <Misc.au3>
#include <IsPressedEx_UDF.au3>
$sec = 10

Opt("MouseCoordMode", 1)
Global $inc, $pos1, $pos2, $sec, $iRet, $hU32_DllOpen, $timer
Mousecheck()

Func KeyboardCheck()
    $hU32_DllOpen = DllOpen("User32.dll")
    MsgBox(1,"Status1","Keyboard Check" & ":" & $timer,1)
    $check = 0
    while 1
        $iRet = _IsPressedEx("[:ALLKEYS:]", $hU32_DllOpen)
        Sleep(75)
        If $iRet = 1 Then
        DllClose($hU32_DllOpen)         
            Return $iRet
        Else
            $check = $check+1
            MsgBox(1,"Status2","Keyboard Check" & ":" & $timer,1)
        EndIf
        If $check > 10 Then
        DllClose($hU32_DllOpen)           
        Return $iRet
        EndIf
    WEnd
    DllClose($hU32_DllOpen)
    Return
EndFunc 

func MouseCheck()
    MsgBox(1,"Status1","Checking for Mouse movement.",1)
    $timer = 0
    MsgBox(1,"Status2","Mouse Check" & ":" & $timer,1)
    While 1
        $pos1 = MouseGetPos(1)
        KeyboardCheck()
        $pos2 = MouseGetPos(1)
        
        If $iRet = 1 Then
            $pos1 = 1
            $pos2 = 2
            $timer = 0
        EndIf
        
        If $pos1 = $pos2 Then 
            $timer = $timer+1
            MsgBox(1,"Status3","Mouse Check" & ":" & $timer,1)
        EndIf
        
        If $timer > $sec Then 
            $answer = MsgBox(292,"Workstation Lock","If you want to continue to work click the YES button.",30)
            If $answer = 7 Then
                Send ("{LWINDOWN} + {l}",0)
            Else
                $timer = 0
            EndIf  
        EndIf
        
    WEnd
EndFunc

Share this post


Link to post
Share on other sites



#Include <Timers.au3>

_Timer_GetIdleTime()

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Is this just a keyboard/mouse idle timer? Seems like your life could be simpler with _TimerGetIdleTime() in the help file.

:D

Edit: @TurionAltec: Great minds thinking alike...

:D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Is this just a keyboard/mouse idle timer? Seems like your life could be simpler with _TimerGetIdleTime() in the help file.

:D

Edit: @TurionAltec: Great minds thinking alike...

:D

wow, so many features, thanks did not know it was in there.

Roger

Share this post


Link to post
Share on other sites

Just in case someone wanted the final product:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=server.ico
#AutoIt3Wrapper_outfile=c:\temp\Idlewindows.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Include <Misc.au3>
#include <IsPressedEx_UDF.au3>
#Include <Timers.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("TrayMenuMode",1)
HotKeySet("+{ESC}", "_Exit")
Switch $cmdline[0]
    Case 1
        $sTime = $cmdline[1]*60000
    Case Else
        MsgBox(0,"Demo Version","This is just an simulated version of the Idle Program." & @CR & "It will display a message at 10 seconds, then wait 15 seconds" & @CR & "and finally automatically lock the workstation." & @CR & @CR & "To use this in a production Mode:" & @CR &"from the command line type the following:" & @CR & "Idlewindows.exe {time in minutes} before idle expiration." & @CR & "To exit the program hold the SHIFT and ESC keys.")
        $sTime = 10000
EndSwitch
$sBkColor = PixelGetColor (20,20)


while 1
    Sleep(1000)
    $iIdleTime = _Timer_GetIdleTime()
    If $iIdleTime > $sTime Then
        GUICreate(" ",@DesktopWidth,@DesktopHeight+20,1,1)
        GUISetBkColor($sBkColor)
        GUISetStyle($WS_POPUPWINDOW,$WS_CAPTION)
        GUISetState(@SW_SHOW)
        $ichoice = MsgBox(262144+1+256,"Workstation Idle Time Exceeded","Press the Cancel button to stop workstation lock.",15)
        If $ichoice = 2 Then
            GUIDelete()
        Else
            Send ("{LWINDOWN} + {l}",0)
            GUIDelete()
        EndIf
        
    EndIf
WEnd
Func _Exit()
     Exit
EndFunc

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0