Shrapnel Posted April 1, 2013 Share Posted April 1, 2013 Hello,I am a newbie to Autoit. As a QA Analyst I was attracted to Autoit to write some automation scrips for regression testing, but I am having some difficulty with the "ControlClick" command.I am wondering if I am having issues with this command because I am not using the full window name "Order Tracking Main "Event Tracking" Screen", but I was trying to stay away from that because the name itself has double quotes in it...Any help/advice is appreciated!Here is what i have coded: ControlClick("Order Tracking Main", "WindowsForms10.BUTTON.app.0.143a722_r15_ad11", "btnNewOrder")And here is the Autoit Window Info Summary of "New Order" button" >>>> Window <<<<Title: Order Tracking Main "Event Tracking" ScreenClass: WindowsForms10.window.8.app.0.143a722_r15_ad1Position: 338, 53Size: 1435, 1004Style: 0x16CF0000ExStyle: 0x00050100Handle: 0x00470834>>>> Control <<<<Class: WindowsForms10.BUTTON.app.0.143a722_r15_ad1Instance: 1ClassnameNN: WindowsForms10.BUTTON.app.0.143a722_r15_ad11Name: btnNewOrderAdvanced (Class): [NAME:btnNewOrder]ID: 4457834Text: New OrderPosition: 282, 6Size: 57, 40ControlClick Coords: 30, 20Style: 0x5601000BExStyle: 0x00000000Handle: 0x0044056A Link to comment Share on other sites More sharing options...
FireFox Posted April 1, 2013 Share Posted April 1, 2013 (edited) Hi,Welcome to the autoit forum Here is the right syntax :ControlClick("[TITLE:Order Tracking Main;CLASS:WindowsForms10.window.8.app.0.143a722_r15_ad1]", "", "[CLASS:WindowsForms10.BUTTON.app.0.143a722_r15_ad1; INSTANCE:1]")I suggest you to read the help file for this function if it's not already done. In particular this.If you have any questions concerning the syntax please ask Edit: You should use the AutoIt3Info tool included in the autoit setup package which is designed to be used with the autoit functions.Br, FireFox. Edited April 1, 2013 by FireFox Shrapnel 1 Link to comment Share on other sites More sharing options...
water Posted April 1, 2013 Share Posted April 1, 2013 Welcome to AutoIt and the forum! Windows Forms Controls seem hard (if even possible) to automate. Please search the forum for "ControlClick WindowsForms" and you will find a few threads on this subject. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
jdelaney Posted April 1, 2013 Share Posted April 1, 2013 (edited) I use [REGEXPCLASS:] to grab those types of control. Works well...such as [REGEXPCLASS:.*BUTTON.*] I think the appended string is dynamic, so shouldn't be hard coded (could be wrong) Edited April 1, 2013 by jdelaney FireFox 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Shrapnel Posted April 1, 2013 Author Share Posted April 1, 2013 Thank you all for the replies. I was unable to get this to work so I just used the below code. I know its not as elegant of a solution, but it works for me Eventually i will go back and try to get this to work the way I wanted, but due to time constraints, i had to take the easy way out MouseClick("left", 650, 120, 1, 0) ;Click "New Order" button Link to comment Share on other sites More sharing options...
ileandros Posted April 1, 2013 Share Posted April 1, 2013 Not all aplications accept controlclick I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Shrapnel Posted April 2, 2013 Author Share Posted April 2, 2013 Ok, i figured out why the code that Firefox provided was not working for me. I was doing the "ControlClick" command right after i launched the program with the "Run" command. I figured out that at that time, "Program Manager" is/was the active window, so i used "WinActivate" to make said program the active window and then the "ControlClick" command worked. here is the code: Run("C:\Program Files (x86)\EventTracking.exe") ;Run Order Tracking sleep(500) ;Wait for screen to load WinActivate("[TITLE:Order Tracking Main]", "") ;Make sure Order Tracking Main is the active window $activeWindowTitle = WinGetTitle("[active]") ;Get the title of the active window and store it for future use ControlClick($activeWindowTitle, "", "[CLASS:WindowsForms10.BUTTON.app.0.143a722_r15_ad1; INSTANCE:1]") Link to comment Share on other sites More sharing options...
Shrapnel Posted April 2, 2013 Author Share Posted April 2, 2013 (edited) even better is the "WinWaitActive" command. (sorry for all the posts, but I figured it might help other noobs) Run("C:\Program Files (x86)\EventTracking.exe") ;Run Order Tracking WinWaitActive("[TITLE:Order Tracking Main]", "") ;Wait until "Order Tracking Main" is the active window ControlClick(WinGetTitle("[active]"), "", "[CLASS:WindowsForms10.BUTTON.app.0.143a722_r15_ad1; INSTANCE:1]") Edited April 2, 2013 by Shrapnel Link to comment Share on other sites More sharing options...
Starstar Posted April 2, 2013 Share Posted April 2, 2013 you can also use controlistview......For example $COMPANY_NAME="Filename.exe" $ControlID1 = ControlListView("Network Connections", "", "SysListView321", "FindItem", $COMPANY_NAME, "AACABLE - DIALER SERVICE");creat an id ControlListView("Network Connections", "", "SysListView321", "Select", $ControlID1);Select some thing witch name is equal $COMPANY_NAME send("{enter}") Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
MuchTex Posted April 2, 2013 Share Posted April 2, 2013 even better is the "WinWaitActive" command. (sorry for all the posts, but I figured it might help other noobs) Run("C:\Program Files (x86)\EventTracking.exe") ;Run Order Tracking WinWaitActive("[TITLE:Order Tracking Main]", "") ;Wait until "Order Tracking Main" is the active window ControlClick(WinGetTitle("[active]"), "", "[CLASS:WindowsForms10.BUTTON.app.0.143a722_r15_ad1; INSTANCE:1]") I've found using this is a little more failsafe: RunWait("C:\Program Files (x86)\EventTracking.exe") ;Run Order Tracking ControlClick(WinGetTitle("[active]"), "", "[CLASS:WindowsForms10.BUTTON.app.0.143a722_r15_ad1; INSTANCE:1]") Link to comment Share on other sites More sharing options...
BrewManNH Posted April 2, 2013 Share Posted April 2, 2013 How is using RunWait a better option? It will pause the script until you exit the program you started, so when does the ControlClick get activated? Shrapnel 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MuchTex Posted April 3, 2013 Share Posted April 3, 2013 How is using RunWait a better option? It will pause the script until you exit the program you started, so when does the ControlClick get activated?You're absolutely right, my apologies. Link to comment Share on other sites More sharing options...
Solution Bowmore Posted April 3, 2013 Solution Share Posted April 3, 2013 As the debeveloper have been kind and given a name to the control this should provide a reliable method of identifying the button in AutoIt. ControlClick("Order Tracking Main", "", "[NAME:btnNewOrder]") Shrapnel 1 "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Shrapnel Posted April 3, 2013 Author Share Posted April 3, 2013 As the debeveloper have been kind and given a name to the control this should provide a reliable method of identifying the button in AutoIt. ControlClick("Order Tracking Main", "", "[NAME:btnNewOrder]") Good point. it also makes the code much more readable. Thank you! 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