Jump to content

Answering an generated message box


 Share

Recommended Posts

Pardon the newbie-ness, just starting out using Autoit, but I'm impressed so far. I'm trying to automate an application and I cannot figure out how to answer an message box that the application generates. I've seen how to use WinWaitActive to watch for the message box, but how do I then issue "Cancel" when it appears (the dialog box is a simple OK/Cancel)? Not sure if it matters or not, but the dialog box does not appear to accept the shortcuts, such as O for OK and C for Cancel.

Thanks for the help!

Link to comment
Share on other sites

  • Moderators

Hi, @weardj, welcome to the forum. You would use the AutoIt Window Info Tool (in the same directory where you installed AutoIt) to get information on the window. That should give you the ControlID of the OK and Cancel buttons. You would then use ControlClick (Check the help file for usage) to click on the appropriate button.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thanks. That's a HUGE help. So I actually was able to get passed it with WinWaitActive/WinClose and it worked perfectly. I also get another popup window that is a little more troublesome, but only has a single OK button. The name of the pop-up window is the same as the program name and a variable text so I cannot use WinClose the same way I did previously. I tried using Send {ENTER} but it doesn't seem to work either. Will ControlClick wait for the window to appear before clicking it or will it have an issue if the pop-up could potentially appear differently on the screen? Is there a way of putting in a variable in the message field for WinClose? I know my message text will start with "The database updated successfully..." but after that the version number will change so it will be different each time. 

Link to comment
Share on other sites

  • Moderators

If there is test on the second window that is not on the first, you can use the second (text) parameter with WinWait. You can then do a ControlClick on that window, or if WinClose is working for you, you can specify the text parameter for that as well.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Is there a way of entering a wildcard in the text? The second windows text states "The database has been updated from <old version #> to <new version #>". Since the version numbers change I can't quote the exact text. 

Link to comment
Share on other sites

  • Moderators

You could just include "The database has been updated from", you don't need to include the entire string. 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

So it looks like the first part isn't actually working either. Here is what I have 

Run("TEST.exe")
WinWaitActive("Test", "The latest version of Test has been downloaded. Test will now close and install the latest version.", "0")
 <strong> <-First dialog box, OK or Cancel</strong>
WinClose("Test", "The latest version of Test has been downloaded. Test will now close and install the latest version.")
WinWaitActive("Test", "The database was successfully", "0") <-Second Dialog box that just needs to be closed or click OK
ControlClick("Test", "The database was successfully","[CLASS:Button, TEXT:OK, Instance:1]")

I noticed that the script seems to get stuck at some point, I'm assuming the WinWaitActive. In my taskbar it will show the script still running, even after everything has completed.

Any help would be appreciated.  

Edited by weardj
Link to comment
Share on other sites

Quote out a line with ";"

Not sure how your <strong> and <-- Second strings are not throwing errors as they are not part of a function and not quoted out in your string.

 

Run("TEST.exe")
WinWaitActive("Test", "The latest version of Test has been downloaded. Test will now close and install the latest version.", "0")
 ;<strong> <-First dialog box, OK or Cancel</strong>
WinClose("Test", "The latest version of Test has been downloaded. Test will now close and install the latest version.")
WinWaitActive("Test", "The database was successfully", "0") ; <-Second Dialog box that just needs to be closed or click OK
ControlClick("Test", "The database was successfully","[CLASS:Button, TEXT:OK, Instance:1]")

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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