Xanatopia Posted October 31, 2008 Share Posted October 31, 2008 Hi all. I've encountered an issue in an application where I have AutoIt execute File -> Exit off of the app menu and then attempt to select a "Yes" button in an exit dialog box to terminate the client app. Unfortunately, running the script doesn't seem to work UNTIL I actually manually select the Application itself using the mouse. Once I click on the app with the mouse the AutoIt script seems to execute properly. I'm guessing that for one reason or another the AutoIt focus isn't on the application itself and that clicking on the application manually sufficiently changes focus for the AutoIt script to finally execute. I've given the AutoIt script sufficient time to run without manually clicking on the App, but no go. The manual step seems to be necessary. Is there something fundamental that I'm missing here in terms of insuring proper AutoIt focus before attempting to manipulate the components of a given running app? Is there a specific AutoIt function that I should be using to insure that an application window is in focus before executing any components of that app? Any help is greatly appreciated. Thanks. -- Jeff Link to comment Share on other sites More sharing options...
TehWhale Posted October 31, 2008 Share Posted October 31, 2008 If you know what the application title is, you can use WinSetOnTop("title", "text") to set it on top so you don't have to manually focus the window. Link to comment Share on other sites More sharing options...
BillLuvsU Posted October 31, 2008 Share Posted October 31, 2008 Also remember that AutoIt is just simulating your input, if you were to do it and it wouldn't work, then it won't work when the script does it. [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
Xanatopia Posted October 31, 2008 Author Share Posted October 31, 2008 If you know what the application title is, you can use WinSetOnTop("title", "text") to set it on top so you don't have to manually focus the window.Hi.Thank you for the advice. I gave the WinSetOnTop function a try, but interestingly enough the Application Window doesn't actually enter it's OnTop state UNTIL I click on the application manually. I also tried using the WinActive function to try to put focus on the application window, but this doesn't seem to have any effect either.Any other thoughts on what might be causing this or other options I should try?Thanks.-- Jeff Link to comment Share on other sites More sharing options...
BillLuvsU Posted October 31, 2008 Share Posted October 31, 2008 Look up the SetForegroundWindow API call in the User32 dll. [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
Xanatopia Posted October 31, 2008 Author Share Posted October 31, 2008 Okay, I figured it out. The primary problem is that I had an existing WinWaitActive line at the top of my script that was restraining the shift in focus. Once I removed this line and used WinActivate I was able to get access to the appropriate windows without issue. Thank you very much to everyone who responded, you've assisted me greatly! :-) -- Jeffrey Nuremburg 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