Jump to content

ControlClick()


Recommended Posts

I know this command is supposed to be simple but I just don't understand how it works, or at least how it works correctly...

I used this

ControlClick("AutoIt Help", "&Display", "3006")

Just to try and test it on the autoit help window that was up on my screen and obviously I did something wrong because it just sits that and does nothing.

I want it to click a button in my GUI that has the following "Control" tab settings

Class: Button

Instance: 2

ClassnameNN: Button2

Name:

Advanced Mode: [CLASS:Button; INSTANCE:2]

ID: 4

Text: Vote For Us

Position: 8, 40

Size: 89, 25

ControlClikc Coords: 55, 13

Style: 0x50010000

ExStyle: 0x00000000

Handel: 0x00000000000A04DE

Now I may be wrong but I used.

ControlClick("AutoIt Script", "", "4")

And got nothing. Can some one give me a brief (or long, w.e you want lol) explanation on what I'm misunderstanding about this function?

Link to comment
Share on other sites

;Function for creating the GUI
Func Main_Form()
    $Form1_1 = GUICreate("Auto v2.0", 341, 173, 1245, 3)
    $NextAccBtn = GUICtrlCreateButton("Next Account", 8, 8, 89, 25)
    $VoteForUsBtn = GUICtrlCreateButton("Vote For Us", 8, 40, 89, 25)
    $ClickBtn = GUICtrlCreateButton(" Click GX100", 8, 72, 89, 25)
    $LogOutBtn = GUICtrlCreateButton("Log Out", 8, 104, 89, 25)
    $RetryBtn = GUICtrlCreateButton("Retry", 135, 64, 97, 25)
    $ReIP = GUICtrlCreateButton("ReIP", 135, 90, 97, 25)
    $ReCordNextAcc = GUICtrlCreateButton("R", 96, 8, 17, 17)
    $ReCordGoButton = GUICtrlCreateButton("Go", 113, 8, 20, 17)
    $ReCordVote = GUICtrlCreateButton("R", 96, 40, 17, 17)
    $ReCordG = GUICtrlCreateButton("G", 96, 72, 17, 17)
    $ReCordX = GUICtrlCreateButton("X", 113, 72, 17, 17)
    $ReCordLogOut = GUICtrlCreateButton("R", 96, 104, 17, 17)
    $CurrentAccLabel = GUICtrlCreateLabel("Current Account:", 136, 8, 84, 17)
    $TotalLCashLabel = GUICtrlCreateLabel("Total LCash:", 136, 24, 64, 17)
    $ElapsedTimeLabel = GUICtrlCreateLabel("Elapsed Time:", 136, 40, 71, 17)
    $BlankCurrentAccLabel = GUICtrlCreateLabel("", 216, 8, 124, 17)
    $BlankTotalLCashLabel = GUICtrlCreateLabel("", 216, 24, 124, 17)
    $BlankElapsedTimeLabel = GUICtrlCreateLabel("", 216, 40, 124, 17)
    $WindowInfoLabel = GUICtrlCreateLabel("Auto v2.0", 0, 152, 340, 20, $SS_SUNKEN)

    GUISetState(@SW_SHOW)
EndFunc

No idea how it would help but ok

Link to comment
Share on other sites

check this that i wrote today.

Oh ok! I think I get it now!

I have to include [CLASS: ] or [iNSTANCE: ] when using it. Thanks! I thought that was just part of the example that was not needed!

I will go test it now.

Link to comment
Share on other sites

Oh ok! I think I get it now!

I have to include [CLASS: ] or [iNSTANCE: ] when using it. Thanks! I thought that was just part of the example that was not needed!

I will go test it now.

One thing, read well the parameters of the function from the help file first, are well described there.

for example.

ControlClick("AutoIt Help", "&Display", "3006")
ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] )

You are missing parameters.

I use the class to identify the windows, because i have the Win7 in spanish languaje, this way i get sure that any person who use my script can run it.

Edited by monoscout999
Link to comment
Share on other sites

Ya, I tried even copying your whole script from that other post did not work. Even using the test scripts

ControlClick("[CLASS:Notepad]", "", "MDIClient1")

With a open notepad does not seem to work.

Link to comment
Share on other sites

Ya, I tried even copying your whole script from that other post did not work.

Did it open the calculator? did you see the tiptools? did you try open the calculator by yourself?

did you attach a console debug to the functions(from the beggining until find the error)?

Link to comment
Share on other sites

I didn't use the whole script only the first few because the tooltips have syntax errors because it needs ToolTip("Text here").

Its ok I found another solution of just using mouseclick, thanks for the help though :)

Link to comment
Share on other sites

  • 2 months later...

ControlClick("AutoIt Help", "&Display", "3006")

I see the problem... I just fixed mine. You are using the Au3Info.exe - "Autoit3 Window Info" tool. You are using the "controlID" and that is not what it is actually looking for - even though the syntax says :

ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] )

Instead of controlID, it really wants the ClassnameNN.

In my example, the controlID was 5009, but I had to change it to the following to get it to work :

ControlClick("Settings for Server","","Button5","primary")
Link to comment
Share on other sites

From the help file for ControlClick

A special description can be used as the controlID parameter used in most of the Control...() functions . This description can be used to identify a control by the following properties:

  • ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screenreaders for the blind and Microsoft tools/APIs may allow you to get this Control ID
  • TEXT - The text on a control, for example "&Next" on a button
  • CLASS - The internal control classname such as "Edit" or "Button"
  • CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"
  • NAME - The internal .NET Framework WinForms name (if available)
  • REGEXPCLASS - Control classname using a regular expression
  • X \ Y \ W \ H - The position and size of a control.
  • INSTANCE - The 1-based instance when all given properties match.
This tends to throw quite a few people, in that the ControlID the function is looking for can be any one of the above properties, so if you can't find one, you might be able to get away with using one of the others.

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...