Sign in to follow this  
Followers 0
richietheprogrammer

Run script depending on an external action

12 posts in this topic

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!!

Share this post


Link to post
Share on other sites

Is this possible at all?

Yes it is.

Then two options

  • Create two scripts one that monitors the messagebox and thereafter runs the other script when encountered
  • Create 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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by MuchTex

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by richietheprogrammer

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

thanks for the reply. Could you please clarify your suggestion or give an example? Thanks you!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

thanks for the ideas everyone. I will look into the suggestions and check back here.

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