VelvetElvis Posted April 20, 2012 Share Posted April 20, 2012 Maybe it's because it's Friday and I'm just burnt, but I can't find the answer to this one. Simply put, I need to trap the application close event for a non-GUI app. I have an app that pings a list of several critical machines every 15 minutes and logs errors. But I also would like to trap and log when the application was closed by a user. With a GUI, I just use this: Case $GUI_EVENT_CLOSE ; Write to log file Exit However, with a non-GUI app, I don't know how, or where to put it. It's probably going to be embarrasingly simple, but I'm stumped. Link to comment Share on other sites More sharing options...
water Posted April 20, 2012 Share Posted April 20, 2012 Use function "OnAutoItExitRegister": Registers a function to be called when AutoIt exits My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
VelvetElvis Posted April 20, 2012 Author Share Posted April 20, 2012 Thank you water! I have this line in my code as well: Opt("TrayMenuMode", 1) ; No tray menu, and no way to pause from tray So the only way to close the app is via the Windows task manager. It appears that OnAutoItExitRegister doesn't work on this kind of forced closure. :-( Thanks again for the head's up on this. Definitely going in my hints file. Link to comment Share on other sites More sharing options...
water Posted April 20, 2012 Share Posted April 20, 2012 So the only way to close the app is via the Windows task manager.To catch this type of event you need a monitoring script that does a ProcessExist every x seconds and then logs a message or whatever and then exits.I usually do it this way:Main process starts the monitoring process and passes the ProcessId plus interval in seconds as paramters to the monitoring exeThe monitoring exe runs in a loop and checks the existance of the passed ProcessID every x seconds. If the process does not exist it writes a log message to a file and exits My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
VelvetElvis Posted April 20, 2012 Author Share Posted April 20, 2012 That's pretty slick. Never would've occurred to me. Thanks! Link to comment Share on other sites More sharing options...
water Posted April 20, 2012 Share Posted April 20, 2012 It's an approach I use in my OutlookEX UDF to wait for pop ups and click them away. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
VelvetElvis Posted April 20, 2012 Author Share Posted April 20, 2012 I take it these are known pop-ups? You wouldn't be able to handle unknown pop-ups, would you? Link to comment Share on other sites More sharing options...
water Posted April 20, 2012 Share Posted April 20, 2012 Yes. You have somehow to decide if the popup is a popup you want to react upon. This can be the window title, some text, a button ID etc. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
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