weardj Posted January 5, 2016 Share Posted January 5, 2016 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 More sharing options...
Moderators JLogan3o13 Posted January 5, 2016 Moderators Share Posted January 5, 2016 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 More sharing options...
weardj Posted January 6, 2016 Author Share Posted January 6, 2016 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 More sharing options...
Moderators JLogan3o13 Posted January 6, 2016 Moderators Share Posted January 6, 2016 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 More sharing options...
weardj Posted January 6, 2016 Author Share Posted January 6, 2016 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 More sharing options...
Moderators JLogan3o13 Posted January 6, 2016 Moderators Share Posted January 6, 2016 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 More sharing options...
weardj Posted January 6, 2016 Author Share Posted January 6, 2016 (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 January 6, 2016 by weardj Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted January 6, 2016 Share Posted January 6, 2016 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 More sharing options...
weardj Posted January 6, 2016 Author Share Posted January 6, 2016 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. Link to comment Share on other sites More sharing options...
Trong Posted January 6, 2016 Share Posted January 6, 2016 (edited) Sorry, but I can ask you is:You try something automatic (auto install software)?And its name? (Name of software)? Edited January 6, 2016 by Trong spelling Regards, Link to comment Share on other sites More sharing options...
weardj Posted January 6, 2016 Author Share Posted January 6, 2016 I actually think i just figured it out. I tried WinWait instead of WinWaitActive. Any gotcha to using WinWait over WinWaitActive? Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted January 6, 2016 Share Posted January 6, 2016 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() 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