Khalil
Khalil

Reputation: 311

ControlClick is not working

My script is supposed to press a button somewhere in my window, upper left. It is not working as it should be. I tried this:

ControlClick ClassNN ThunderRT6UserControlDC29, ahk_class ThunderRT6FormDC

Yet it doesn't work. I tried the manual option:

Controlclick x160 y60, ....

But that doesn't work as well.

Eventually I resorted to a mere:

Click 160, 60 and that does work.

I was wondering why it is behaving like that? Also, is there a way for merely the button to get pressed without the mouse actually going all the way over there. I looks stupid and it is slow. The main reason for me asking this question is because it is closely related to another question I posed: How to obtain textual contents from a window The common denominator is that anything with classNN and ahk_class seems to be problematic.

Upvotes: 4

Views: 7911

Answers (4)

ADJenks
ADJenks

Reputation: 3424

I finally found my own solution after skimming the documentation more thoroughly:

https://autohotkey.com/docs/commands/ControlClick.htm#Reliability

You can specify NA as the sixth parameter to wait for the mouse button to lift. I found that when firing Control, Check, ,Button1 prior to ControlClick the click didn't work, but adding the NA to the end somehow magically fixed it. I suppose a click was being simulated and had not yet lifted.

Upvotes: 1

go1
go1

Reputation: 1

Controlclick x160 y60,A,,Left,1, NA

Manual option like that should work,at least in my case it worked.

Left = your mouse button pressed 
1 = number of clicks
A = Active Window

Also options to retrieve contents from the games or retrieve variables from other autohotkey parts for ControlClicks or SendMessage/PostMessage seem to not work yet.

Upvotes: 0

bgmCoder
bgmCoder

Reputation: 6370

First, make sure you have the capitalization correct. controlclick is case and space sensitive - everything in the name has to be correct.

Second, for your mouse-moving issue - first save the position of your mouse, then controlclick, and then put your mouse back where you found it. The mouse will only be out of place for the duration of either the click or the timeout. 160ms is not noticeable.

You might also try using ahk to activate the window, bringing it the front, and then seeing if you can tab through the controls to the one you want, and then push it by sending keys like space or return to the window in the forefront (which you have activated). This avoids using controlclick altogether. Some windows can be tricky.

Upvotes: 0

user2628808
user2628808

Reputation: 51

Try running script as a administrator (if you're on Windows 7 or Vista)

Upvotes: 5

Related Questions