4

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.

Community
  • 1
  • 1
Khalil
  • 311
  • 5
  • 16
  • 1
    Leave out the "ClassNN": `ControlClick, ThunderRT6UserControlDC29, ahk_class ThunderRT6FormDC`. And why are `ahk_class` or `ClassNN` problematic? – MCL Aug 05 '13 at 09:12
  • I tried that but it doesn't work. They are problematic because anything related to them seems to be not working. – Khalil Aug 05 '13 at 14:13

4 Answers4

5

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

1

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.

ADJenks
  • 2,973
  • 27
  • 38
0

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.

Community
  • 1
  • 1
bgmCoder
  • 6,205
  • 8
  • 58
  • 105
  • No, ControlClick is not case-sensitive, nothing in AutoHotkey is. The person you linked to was saying that what you SEND is case-sensitive. That is, instead of sending `A`, send `{SHIFTDOWN}A{SHIFTUP}`. And for the record, this is not correct, you can indeed send capital-letters. Ostensibly, whatever program Oleg was trying to automate has some weird quirk that has trouble receiving capital-letters from AHK (though he might have been able to resolve it by using different send-modes). Moreover, `ControlClick` doesn't send letters, it sends clicks, so capitalization is completely irrelevant. – Synetech Nov 03 '22 at 23:18
  • Wow - that post is from a long time ago. I'm not sure I meant to say that `controlclick` is case-sensitive, because you are right, nothing in ahk is case-sensitive (and it's one of the things I love about the syntax) - it's that the window title/control name is when you try to match it. – bgmCoder Nov 04 '22 at 13:39
0
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.

go1
  • 1
  • 2