richietheprogrammer Posted April 6, 2013 Share Posted April 6, 2013 Hello all, I am trying to see if it is possible to execute the script when a message appears. I want the script to only execute when a specific messagebox is ran (from another application). Is this possible at all? Thanks for any help!! Link to comment Share on other sites More sharing options...
PhoenixXL Posted April 6, 2013 Share Posted April 6, 2013 Is this possible at all?Yes it is.Then two optionsCreate two scripts one that monitors the messagebox and thereafter runs the other script when encounteredCreate one script with both the functions of monitoring and executing the processments required.The latter is recommended.P.S. : The MsgBox should be unique you can check the Title and the ClassName for this purpose.Regards My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
MuchTex Posted April 6, 2013 Share Posted April 6, 2013 (edited) To build upon what PhoenixXL said, there are two different functions which can make this pretty easy. If the messagebox is its own window (ie. you can close it from the taskbar), just use the WinWait() function. If it's not its own window (ie. you can can't close it just from the task bar) use the ControlFocus() function. Both of these can be used with a While...WEnd loop to execute the processments required. This 5 line code would do the trick if you are able to just use WinActive(): While 1 sleep(100) If WinActive("Enter Window Title Here") Then ;Enter processments required here EndIf WEnd Edited April 6, 2013 by MuchTex Link to comment Share on other sites More sharing options...
water Posted April 6, 2013 Share Posted April 6, 2013 Place a "Sleep(100)" in your While loop so it doesn't eat up all CPU cycles. 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...
MuchTex Posted April 6, 2013 Share Posted April 6, 2013 Place a "Sleep(100)" in your While loop so it doesn't eat up all CPU cycles.Yep, I'll edit that into my example. Admittedly I am not the most efficient programmer in many regards but especially when it comes to eating up the CPU on a computer. Definitely something I need to work on. Link to comment Share on other sites More sharing options...
water Posted April 6, 2013 Share Posted April 6, 2013 That's learning by doing - most of the things I know today I learned this way 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...
richietheprogrammer Posted April 6, 2013 Author Share Posted April 6, 2013 (edited) Thanks for the suggestions everyone. However the suggested solution doesn't work for me still, as it still presents the same concern. Therefore, let me clarify what I am looking for: There is a local program installed on our computers that displays a reboot prompt, but does not ask for confirmation if the user chooses "reboot now". I would like to customize a messagebox to get verification before rebooting. I am able to write the code for the messagebox, and for detecting when that box is shown (using winwait as suggested), however, I do not want a script running on all these computers at all times that just waits for that message box to open. Basically when that program displays that messagebox, I will have the code choose the "reboot later" option and then display a customized messagebox with both options present, followed by another confirmation box if "reboot now" is chosen. I hope this is clear enough, but I am looking for a way to detect that messagebox without having an autoit script running at all times. Once detected, the autoit script should run. I apologize if what I am asking for sounds ridiculous and is not possible (because I do not see how it would be possible) but you guys never cease to amaze me with ideas Thanks for any help! Edited April 6, 2013 by richietheprogrammer Link to comment Share on other sites More sharing options...
PhoenixXL Posted April 7, 2013 Share Posted April 7, 2013 If you don't want a Process try with a Service, It should work I guess My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
richietheprogrammer Posted April 7, 2013 Author Share Posted April 7, 2013 thanks for the reply. Could you please clarify your suggestion or give an example? Thanks you! Link to comment Share on other sites More sharing options...
PhoenixXL Posted April 7, 2013 Share Posted April 7, 2013 My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
kylomas Posted April 7, 2013 Share Posted April 7, 2013 richie, You can trigger actions (run your script) based on specific log events using the task schedular. If the action that you are looking for triggers a log event then you may be able to key off that. Never used it so you'll have to do the research, just another idea. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
richietheprogrammer Posted April 7, 2013 Author Share Posted April 7, 2013 thanks for the ideas everyone. I will look into the suggestions and check back here. 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