Sign in to follow this  
Followers 0
win2k

Error Check and Script Halting ?

4 posts in this topic

What would be the best way to check for errors and halt a script if it "gets off track" ? Like say for some odd reason the computer lags and it sends and enter before some text is done being entered. The script will go haywire and well i would like to figure out a way to kill the script if that happens. I am usually working in this window %systemroot%\system32\services.msc

Share this post


Link to post
Share on other sites



If you are there to monitor the situation you may consider the following...

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

I hope the above helps. Other wise it seems you will need to create your own "Error Checking" function that you would need to call every so often to be sure that the values you have wanted are in the right places.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

hrmm would there be a way to halt the script when the "services" window became inactive?

I guess something along the lines of my psuedo code

HotKeySet("{END}", "Terminate")

If (insert some command that checks to see if a window is inactive) then

send("{END}")

end if

Func Terminate()

Exit 0

EndFunc

I dont know if WinWaitNotActive does that or not

Share this post


Link to post
Share on other sites

I dont think WinWaitNOTActive is quite what you are looking for as that would in essence pause your script until it is active.

Something more along the lines of what you are wanting would be...

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
    If Not WinActive("Services Window Title") Then
        Send("{PAUSE}")
    EndIf
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Use that "If" statement throughout your entire script to make sure that it checks whether or not it is the active window before entering more text into the window. Be sure to use the proper title of the window.

I hope this helps further. You can change the {PAUSE} to {ESC} if you are wanting to exit and not pause.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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