Jump to content

Recommended Posts

Posted

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

Posted

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.

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
Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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.

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
Posted

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.

Posted

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.

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...