weardj

Answering an generated message box

12 posts in this topic

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!

Share this post


Link to post
Share on other sites



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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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. 

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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. 

Share this post


Link to post
Share on other sites

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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
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]")

 

Share this post


Link to post
Share on other sites

They are not actually in the code, I just used them as comments on my post here so you know what the application was doing at each part of the script.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Sorry, but I can ask you is:
You try something automatic (auto install software)?
And its name? (Name of software)?

Edited by Trong
spelling

Regards,
 

Share this post


Link to post
Share on other sites

I actually think i just figured it out. I tried WinWait instead of WinWaitActive. Any gotcha to using WinWait over WinWaitActive?

Share this post


Link to post
Share on other sites

Wait just is if the window exists, if you want to do sends to the window it may need to be active.

WinWaitActive waits for the window to be active (in focus)

I personally always use the combo of WinWait() followed by WinActivate()

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