gustavo21 Posted October 8, 2013 Share Posted October 8, 2013 Hello everyone. Im trying to do a script to do the next: 1- Run a program (and wait til it close, because i call the autoit script with scart /wait from CMD) 2- Check if a window is opened (not allways happens), focus and send keys I wrote this, and obviously its not working: Run("wpi2.exe") WinWait("[CLASS:HTML Application Host Window Class]") If WinActive("[CLASS:#32770]") Then Send("{TAB}") Send ("{SPACE}") EndIf WinWaitClose("[CLASS:HTML Application Host Window Class]") The windows i need to close (#32770) sometimes is opened before this script is executed, Its not the result of the program im calling in first line. I will apreciate your help! Thanks in advance. Link to comment Share on other sites More sharing options...
boniakowski Posted October 9, 2013 Share Posted October 9, 2013 Hello everyone. Im trying to do a script to do the next: 1- Run a program (and wait til it close, because i call the autoit script with scart /wait from CMD) 2- Check if a window is opened (not allways happens), focus and send keys I wrote this, and obviously its not working: Run("wpi2.exe") WinWait("[CLASS:HTML Application Host Window Class]") If WinActive("[CLASS:#32770]") Then Send("{TAB}") Send ("{SPACE}") EndIf WinWaitClose("[CLASS:HTML Application Host Window Class]") The windows i need to close (#32770) sometimes is opened before this script is executed, Its not the result of the program im calling in first line. I will apreciate your help! Thanks in advance. you tried alredy winwaitactive ? ;Wait for the window "[CLASS:Notepad]" to exist and be active WinWaitActive("[CLASS:Notepad]") ;Wait a maximum of 5 seconds for "[CLASS:Notepad]" to exist and be active WinWaitActive("[CLASS:Notepad]", "", 5) you use autoit window info to get de correct title or class? Link to comment Share on other sites More sharing options...
gustavo21 Posted October 11, 2013 Author Share Posted October 11, 2013 Yes, The problem i have is to send key only if the window is active, because i have to send tab and space and if the windows in not active theese commands will close another app. Also i need to wait until the first app i run (wpi.exe) close. Thanks!! Link to comment Share on other sites More sharing options...
somdcomputerguy Posted October 11, 2013 Share Posted October 11, 2013 (edited) Try this then.. RunWait("wpi2.exe") While 1 If WinActive("[CLASS:#32770]") Then Send("{TAB}{SPACE}") ExitLoop EndIf Sleep(100) WEnd Note that if the window in question is not active, it will have to be activated manually (IOW, by you). Also, the ExitLoop statement can be replaced by Exit, if there is not going to be any code added after the While loop. Edited October 11, 2013 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
gustavo21 Posted October 11, 2013 Author Share Posted October 11, 2013 Can I use "WinActivate" to active the window? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted October 11, 2013 Share Posted October 11, 2013 Can I use "WinActivate" to active the window? What does the Help file say about that function? - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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