silentkiller1987 Posted March 29, 2011 Posted March 29, 2011 (edited) Hi, I'm doing a testing on an application and i'm stuck. After logging into the application, a value will be chosen from a combobox. After which, a confirmation window will pop-up. The problem is, the it does not focus on the pop-up window hence, could not click the "OK" Button. Here's my codes: ControlClick("Software","","[ID:63]") ;click on the button to enable dropdown ControlCommand ( "Software", "", "[ID:66]", "ShowDropDown","" ) ;dropdown and show values Sleep(500) ControlCommand ( "Software", "", "[ID:66]", "SelectString","1" ) ;choose 1 from the dropdown WinWaitActive("Confirmation") ;focus on Confirmation window ControlClick("Confirmation", "", "[CLASS:Button; INSTANCE:1; TEXT:OK]") ;click ok from confirmation window I have checked the information of the button from "AutoIt Window Info" and everything seems to be correct. I've tried using Send("{ENTER"}), still can't solve it. Any suggestion ? Edited March 29, 2011 by silentkiller1987
Varian Posted March 29, 2011 Posted March 29, 2011 (edited) Have you tried removing the "; TEXT:OK" from the ControlClick line? I would not use INSTANCE and TEXT together...just use one or the other. The only time that I use the "TEXT" field is when there are multiple buttons in the same Class and either the instance changes or it's more logical to use the text of the button. I would think that it is rare to impossible for there to be more than 1 instance of the same button class, unless it's Java or some strange window. Also, you may try ControlSend instead of Send. I would try sending the key(s) to the window without a Control specified. You may also want to send {SPACE} or check for Hotkeys (like Alt-O or Alt-K or Alt-N) Lastly, it's not a bad idea to try and get a Handle for the button before the button is clicked. A loop likeWinWait("Confirmation", "") Do Local $hCtrl = ControlGethandle("Confirmation", "", "[CLASS:Button; INSTANCE:1]") Sleep(50) Until $hCtrl ControlClick("Confirmation", "", $hCtrl) Edited March 29, 2011 by Varian
silentkiller1987 Posted March 30, 2011 Author Posted March 30, 2011 Thanks for the reply! I removed TEXT as what u mentioned. And I used Send to enter the parameters and it worked. I realized the problem was due to the Confirmation window because the Control parameters are not defined hence, it does not get active by WinWaitActive. This is my final codes: ControlClick("Software","","[ID:63]") ;click on attn button ControlCommand ( "Software", "", "[ID:66]", "ShowDropDown","" ) Sleep(1000) [color="#008000"]Send("1")[/color] ;select 1 [color="#008000"]Send("{DOWN}") [/color];Down arrow to Enter WinWaitActive("Confirmation") sleep(500) ControlClick("Confirmation", "", "[CLASS:Button; INSTANCE:1;]") ;click ok Thanks again
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