Sign in to follow this  
Followers 0
Ballad

ControlClick Help

11 posts in this topic

#1 ·  Posted (edited)

Hello, I'm trying to click a specific button in a program that's running using ControlClick. No matter what I do it seems that the button is never pressed. Currently i'm trying to press the 3 button in the program

Here are some code snippets I tried:

[/code]
ControlClick ($title, "3","[ID:20]")
ControlClick ($title, "3","[CLASS:N20; INSTANCE:1]")
ControlClick ($title, "3","[CLASSNN:N20]")
[code]

Button Info:

Class: N20

Instance: 1

ClassnameNN: N201

Name:

Advanced (Class): [CLASS:N20; INSTANCE:1]

ID: 20

The program I am clicking in will not be the active window which is why I am using ControlClick so I'm pretty sure that's not the problem. If anybody can tell me what's wrong or point me in the right direction it would be great. Any and all help is appreciated.

Edited by Ballad

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How do you know the $title, "3" part is correctly identifying the window? Correct match to the window has to come before matching the control.

On the control, either "[CLASS:N20; INSTANCE:1]" or "[iD:20]" should have worked, but the ClassNN would be "N201" (append the instance number for 'NN').

:blink:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I did state the variable $tiltle as the window first but to be sure I dropped it and just put the name of the window in. So now I have ControlClick ("On-Screen Keyboard", "3","[CLASS:N20; INSTANCE:1]") This does not work either. I'm not sure however of the "3". I tried leaving that parameter blank and that also did not work. The "3" is the text of the button I want to click correct? Thanks.

Share this post


Link to post
Share on other sites

Post the full summary tab of AU3Info.exe (you only posted the control info above). With Class/Title info we can help you verify you have the window first. Hint: Test that first with something like WinGetHandle() or WinGetTitle() before moving on to the control.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

This is the Control and Window Summary:

>>>> Window <<<<

Title: On-Screen Keyboard

Class: OSKMainClass

Position: 75, 288

Size: 612, 195

Style: 0x14CA0000

ExStyle: 0x08040108

Handle: 0x0898037E

>>>> Control <<<<

Class: N20

Instance: 1

ClassnameNN: N201

Name:

Advanced (Class): [CLASS:N20; INSTANCE:1]

ID: 20

Text: #

Position: 84, 30

Size: 26, 22

ControlClick Coords: 14, 12

Style: 0x54800000

ExStyle: 0x00000000

Handle: 0x00C30526

If you need more just ask. I now see the text for my button is # so I tried "#" instead of "3". No luck. I really appreciate all the help.

Share this post


Link to post
Share on other sites

The text is any visible text to identify the window. That has nothing to do with identifying the control.

Try this:

$hWin = WinGetHandle("[CLASS:OSKMainClass; TITLE:On-Screen Keyboard]")
If $hWin Then
    ConsoleWrite("Got $hWin = " & $hWin & @LF)
    $hButton = ControlGetHandle($hWin, "", "[CLASS:N20; INSTANCE:1]")
    If $hButton Then
        ConsoleWrite("Got $hButton = " & $hButton & @LF)
    Else
        ConsoleWrite("Error! Failed to get $hButton = " & $hButton & @LF)
    EndIf
Else
    ConsoleWrite("Error! Failed to get $hWin = " & $hWin & @LF)
EndIf

If that works, then you should be able to ControlClick($hWin, "", $hButton).

However, INSTANCE:1 is suspicious for a key on an on-screen keyboard, because there are many. What does that look like if you point to a different key? Is it still "[CLASS:N20; INSTANCE:1]" no matter which key you point at? If so, that is the control ID for the whole keyboard, not a particular button on the keyboard.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I couldn't get your script running for some reason but I tested the code snippets to get the variables $hWin and $hButton. As far as I know something is being returned but I can't be positive if it's the right window or button. I implemented the "Get handle" codes but nothing happened once again. As for your question when the cursor is over other buttons the Control class changes (N21 or N22, ect.) however the instance is always 1. Any ideas?

Edited by Ballad

Share this post


Link to post
Share on other sites

What was displayed on the console when you ran the code in my last post?

You should have gotten something like:

Got $hWin = 0x0898037E
Got $hButton = 0x00C30526

Those hex values are the handles, and should match what you see in the summary tab of AU3Info.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

No message poped up. I ran the script and nothing :/ Maybe I did something wrong though. The script would run but no message would come. The On-Screen Keyboard should be available on any Dell. Start> All Programs> Accessories> Accessibility> On-Screen Keyboard. In case you wanted to test your script. Like I said last post all the buttons have a different class but the instance is always 1. Perhaps this could cause problems?

Share this post


Link to post
Share on other sites

Notice those are ConsoleWrite() functions, which means you need to run my demo in SciTE and look for the output in the console pane at the bottom of the SciTE window. You can re-write it with MsgBox() instead of ConsoleWrite() if that's an issue for you.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Ah thank you. I'm sorry, you're talking to a beginer. I got your script to work and both hex codes match up perfectly. So I tried:

$hWin = WinGetHandle("[CLASS:OSKMainClass; TITLE:On-Screen Keyboard]")
$hButton = ControlGetHandle($hWin, "", "[CLASS:N20; INSTANCE:1]")
sleep(5000);;to put cursor in Notepad to make sure it clicked the keyboard
ControlClick($hWin, "", $hButton)

Still no luck however. I have no idea whats wrong. I'm not even sure where the problem could be. I appreciate all the help you've already given me.

Edited by Ballad

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  
Followers 0