class CExternalProcessSentry { number PID number periodicTaskID CExternalProcessSentry( object self ) { Result("\n Debug Info: Created object " + self.ScriptObjectGetID() ); } ~CExternalProcessSentry( object self ) { Result("\n Debug Info: Removed object " + self.ScriptObjectGetID() ); } void Launch( object self, string command, number checkInterval_sec ) { // Launch external application and // continue script immediately PID = LaunchExternalProcessAsync( command ) if ( 0 == PID ) Throw( "Could not launch external command.\n\n" + command ) // Register periodic checking periodicTaskID = AddMainThreadPeriodicTask( self, "CheckAndNotify", checkInterval_sec ) } void CheckAndNotify( object self ) { if ( IsExternalProcessActive( PID ) ) { Result( "\n\t The external process [" + PID +"] is still active @" + GetTime(1) ) } else { Result( "\n\t The external process [" + PID +"] is no longer active." ) // Unregister periodic checking RemoveMainThreadTask( periodicTaskID ) } } } // Launches NotePad application and check every 5 sec if it is still running. string msg = "notepad.exe" number checkTime = 5 Alloc( CExternalProcessSentry ).Launch( msg, checkTime )