gilk Posted January 13, 2005 Posted January 13, 2005 I'm trying to run a housekeeping script that executes cleanup,defrag and some other tasks at night. For safety reasons I want all the active windows to close (unless there is unsaved files, in which case I want the script to terminate). the problem is that the computers lock i.e. the Win2K login screen is activated. I tried the following : for $j=1 to 5 For $i = 1 to 20 Step 1 $title=WinGetTitle("") if $title="Program Manager" then ExitLoop(1) ;;; prevent shutdown WinClose($title) $success=WinWaitClose($title,"",10) if $success=0 then ExitLoop(1) ;;;; to prevent loss of unsaved files Next Next it works when the computer is not locked, but will not do the job when locked. I don't want to use winkill because it may cause loss of unsaved files advice anyone ?
DirtyBanditos Posted January 13, 2005 Posted January 13, 2005 I'm trying to run a housekeeping script that executes cleanup,defrag and some other tasks at night. For safety reasons I want all the active windows to close (unless there is unsaved files, in which case I want the script to terminate). the problem is that the computers lock i.e. the Win2K login screen is activated.I tried the following :for $j=1 to 5 For $i = 1 to 20 Step 1 $title=WinGetTitle("") if $title="Program Manager" then ExitLoop(1) ;;; prevent shutdown WinClose($title) $success=WinWaitClose($title,"",10) if $success=0 then ExitLoop(1) ;;;; to prevent loss of unsaved files NextNextit works when the computer is not locked, but will not do the job when locked.I don't want to use winkill because it may cause loss of unsaved filesadvice anyone ?<{POST_SNAPBACK}>Hi look this link i found it wis the search func on his forums))I hope this help you out.http://www.autoitscript.com/forum/index.php?showtopic=7523expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.0 ; Language: English ; Platform: Win9x / NT ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template AutoIt script. ; ; ---------------------------------------------------------------------------- ; Setup some useful options that you may want to turn on - see the helpfile for details. ; Expand all types of variables inside strings ;Opt("ExpandEnvStrings", 1) ;Opt("ExpandVarStrings", 1) ; Require that variables are declared (Dim) before use (helps to eliminate silly mistakes) ;Opt("MustDeclareVars", 1) $var1=0 $var2=0 $var3=0 $wrong=0 While 1 If _IsPressed('01') = 1 Then $var1=1 If _IsPressed('04') = 1 Then $var2=1 If _IsPressed('02') = 1 Then $var3=1 If _IsPressed('01') = 0 Then $var1=0 If _IsPressed('04') = 0 Then $var2=0 If _IsPressed('02') = 0 Then $var3=0 ; if $var1 and $var2=0 and $var3 then;101 $wrong=1 ;tooltip ("wrong") sleep (500) tooltip("") endif ; if $var1=0 and $var2 and $var3 then;011 $wrong=1 ;tooltip ("wrong") sleep (500) ;tooltip("") endif ; ; if $var1=0 and $var2 and $var3=0 then;010 $wrong=1 ;tooltip ("wrong") sleep (500) ;tooltip("") endif ; if $var1=0 and $var2=0 and $var3=0 and $wrong=1 then; reset $wrong=0 ;tooltip ("reseted") sleep (500) ;tooltip("") endif ; ; If $var1 and $var2 and $var3 and $wrong=0 then; 111 pressed tooltip ("Machine Shutting Down....") sleep (2000) shutdown(9) tooltip("") endif Sleep(10) Wend Exit Func _IsPressed($hexKey) ; $hexKey must be the value of one of the keys. ; _IsPressed will return 0 if the key is not pressed, 1 if it is. Local $aR, $bRv;$hexKey $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) ;If $aR[0] = -32767 Then If $aR[0] <> 0 Then $bRv = 1 Else $bRv = 0 EndIf Return $bRv EndFunc;==>_IsPressed ; ---------------------------------------------------------------------------- ; Script Start - Add your code below here ; ----------------------------------------------------------------------------
gilk Posted January 13, 2005 Author Posted January 13, 2005 (edited) Hey DirtyBanditos, Thnx for the tip - it is useful for other stuff I'm thinking of, but it doesn't solve the main problem i.e. closing active windows (not the OS , but the applications) when the computer is locked All the best gilk Edited January 13, 2005 by gilk
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