Jump to content
Sign in to follow this  
Shrapnel

ControlClick Help

Recommended Posts

Shrapnel

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" Screen

Class: WindowsForms10.window.8.app.0.143a722_r15_ad1

Position: 338, 53

Size: 1435, 1004

Style: 0x16CF0000

ExStyle: 0x00050100

Handle: 0x00470834

>>>> Control <<<<

Class: WindowsForms10.BUTTON.app.0.143a722_r15_ad1

Instance: 1

ClassnameNN: WindowsForms10.BUTTON.app.0.143a722_r15_ad11

Name: btnNewOrder

Advanced (Class): [NAME:btnNewOrder]

ID: 4457834

Text: New Order

Position: 282, 6

Size: 57, 40

ControlClick Coords: 30, 20

Style: 0x5601000B

ExStyle: 0x00000000

Handle: 0x0044056A

Share this post


Link to post
Share on other sites
FireFox

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 by FireFox
  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jdelaney

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 by jdelaney
  • Like 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.

Share this post


Link to post
Share on other sites
Shrapnel

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 :P

MouseClick("left", 650, 120, 1, 0) ;Click "New Order" button

Share this post


Link to post
Share on other sites
ileandros

Not all aplications accept controlclick


I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
Shrapnel

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]")

Share this post


Link to post
Share on other sites
Shrapnel

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 by Shrapnel

Share this post


Link to post
Share on other sites
Starstar

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."

Share this post


Link to post
Share on other sites
MuchTex

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]")

Share this post


Link to post
Share on other sites
BrewManNH

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?

  • Like 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 Gude
How 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

Share this post


Link to post
Share on other sites
MuchTex

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.

Share this post


Link to post
Share on other sites
Bowmore

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]")
  • Like 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

Share this post


Link to post
Share on other sites
Shrapnel

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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×