Sign in to follow this  
Followers 0
numdig

Supervised PIDs - Close all upon OnAutoItExit call

1 post in this topic

#1 ·  Posted (edited)

Here are two samples for launching and keeping an eye on other applications.

It is handy when it comes to dealing with webservers: we can keep the little AutoIT icon in the taskbar and terminate the webserver when needed.

The important bit is:

Global $SUPERVISED_PID___GLOBAL = 0
OnAutoItExitRegister("OnAutoItExitV01")

And the function:

Func OnAutoItExitV01()
    ; was there an error?
    If @exitCode Then Return
    ; close by clicking on exit of the systray?
    If @exitMethod = 2 Then
        ; close the grand-children as well
        $list = _ProcessGetChildren($SUPERVISED_PID___GLOBAL)
        If IsArray($list) Then
            For $i = 1 To $list[0][0]
                If ProcessExists($list[$i][0]) Then
                    ProcessClose($list[$i][0])
                    ProcessWaitClose($list[$i][0])
                EndIf
            Next
        EndIf
        ; close the main process
        If ProcessExists($SUPERVISED_PID___GLOBAL) Then ProcessClose($SUPERVISED_PID___GLOBAL)
    EndIf
EndFunc   ;==>OnAutoItExitV01

Credits: SmOke_N for the _ProcessGetChildren function

( http://www.autoitscript.com/forum/index.php?showtopic=78445 )

LaunchTrac.au3

LaunchApacheOnly.au3

_ProcessGetChildren.au3

LaunchZendApacheOnly.au3

Edited by Chess

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