Is click faster than controlclick? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fona
Posts: 65
Joined: 07 Apr 2022, 06:43

Is click faster than controlclick?

Post by fona » 21 May 2022, 20:26

Hi everyone,
I prefer sometimes controlclick just because I can't see how the mouse moves and it looks somehow better.

Code: Select all

ControlClick, x720 y486, ahk_class MozillaWindowClass,,Left,1,NA

Code: Select all

Click 720, 486
But is there any difference in speed. Let's look at the simple code above. Which method is faster? Is it better to use click than controlclick, if there is no specific classNN

Rohwedder
Posts: 7644
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Is click faster than controlclick?  Topic is solved

Post by Rohwedder » 22 May 2022, 00:25

Hallo,
not here: Click 68ms
ControlClick 27ms

Code: Select all

DllCall("QueryPerformanceFrequency",Int:="Int64*",Freq),Time:=Count:=0
q::
DllCall("QueryPerformanceCounter",Int,Count1)
;Time duration measurement of this:
	ControlClick, x720 y486, ahk_class MozillaWindowClass,,Left,1,NA
	; Click 720, 486
;Multiple execution increases accuracy by means of averaging!
DllCall("QueryPerformanceCounter",Int,Count2)
ToolTip,% "Time: " Round((Time+=(Count2-Count1)/Freq*1.E6)/++Count) " µs"
Return
Probably because ControlClick does not need to move the cursor.

fona
Posts: 65
Joined: 07 Apr 2022, 06:43

Re: Is click faster than controlclick?

Post by fona » 22 May 2022, 06:22

Rohwedder wrote:
22 May 2022, 00:25
Hallo,
not here: Click 68ms
ControlClick 27ms

Code: Select all

DllCall("QueryPerformanceFrequency",Int:="Int64*",Freq),Time:=Count:=0
q::
DllCall("QueryPerformanceCounter",Int,Count1)
;Time duration measurement of this:
	ControlClick, x720 y486, ahk_class MozillaWindowClass,,Left,1,NA
	; Click 720, 486
;Multiple execution increases accuracy by means of averaging!
DllCall("QueryPerformanceCounter",Int,Count2)
ToolTip,% "Time: " Round((Time+=(Count2-Count1)/Freq*1.E6)/++Count) " µs"
Return
Probably because ControlClick does not need to move the cursor.
So, ControlClick is usually almost 3x faster, did I understand it correctly? Just wanted to make sure:) Thank you Rohwedder

Rohwedder
Posts: 7644
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Is click faster than controlclick?

Post by Rohwedder » 22 May 2022, 06:37

I can't generalize. I don't know how the times are on other computers.
Just measure it yourself with this script.

fona
Posts: 65
Joined: 07 Apr 2022, 06:43

Re: Is click faster than controlclick?

Post by fona » 22 May 2022, 06:56

Rohwedder wrote:
22 May 2022, 06:37
I can't generalize. I don't know how the times are on other computers.
Just measure it yourself with this script.
Just tried your script. Wonderful. From my side, it seems like click is faster than controlclick in most cases, and idk why. Click's performance is sometimes 2ms. Controlclick should have actually been faster, as you have said "it doesn't need to move the cursor"

User avatar
boiler
Posts: 16949
Joined: 21 Dec 2014, 02:44

Re: Is click faster than controlclick?

Post by boiler » 22 May 2022, 07:12

Did you just compare a bare Click without specifying a location, which clicks at the current mouse position?

fona
Posts: 65
Joined: 07 Apr 2022, 06:43

Re: Is click faster than controlclick?

Post by fona » 22 May 2022, 07:26

Rohwedder wrote:
22 May 2022, 00:25
Hallo,
not here: Click 68ms
ControlClick 27ms

Code: Select all

DllCall("QueryPerformanceFrequency",Int:="Int64*",Freq),Time:=Count:=0
q::
DllCall("QueryPerformanceCounter",Int,Count1)
;Time duration measurement of this:
	ControlClick, x720 y486, ahk_class MozillaWindowClass,,Left,1,NA
	; Click 720, 486
;Multiple execution increases accuracy by means of averaging!
DllCall("QueryPerformanceCounter",Int,Count2)
ToolTip,% "Time: " Round((Time+=(Count2-Count1)/Freq*1.E6)/++Count) " µs"
Return
Probably because ControlClick does not need to move the cursor.
Is there a small mistake? Shouldn't q be at the top of the code?

Code: Select all

q::
DllCall("QueryPerformanceFrequency",Int:="Int64*",Freq),Time:=Count:=0
DllCall("QueryPerformanceCounter",Int,Count1)
;Time duration measurement of this:
	;ControlClick, x722 y487, ahk_class MozillaWindowClass,,Left,1,NA
	Click 722, 487
;Multiple execution increases accuracy by means of averaging!
DllCall("QueryPerformanceCounter",Int,Count2)
ToolTip,% "Time: " Round((Time+=(Count2-Count1)/Freq*1.E6)/++Count) " µs"
Return
But it works like this. Is it okay?

fona
Posts: 65
Joined: 07 Apr 2022, 06:43

Re: Is click faster than controlclick?

Post by fona » 22 May 2022, 07:32

boiler wrote:
22 May 2022, 07:12
Did you just compare a bare Click without specifying a location, which clicks at the current mouse position?
No, I specify the location for Click and just use the code suggested by Rohwedder. Could you also try it and see how they both perform.

fona
Posts: 65
Joined: 07 Apr 2022, 06:43

Re: Is click faster than controlclick?

Post by fona » 22 May 2022, 09:12

.....................
Last edited by fona on 22 May 2022, 10:10, edited 1 time in total.

User avatar
boiler
Posts: 16949
Joined: 21 Dec 2014, 02:44

Re: Is click faster than controlclick?

Post by boiler » 22 May 2022, 09:30

fona wrote:
22 May 2022, 07:26
Is there a small mistake? Shouldn't q be at the top of the code?
No, he made no mistake. You would be making the mistake by moving it. You are not understanding how it works and why that line can’t be in the hotkey subroutine for it to work as intended. That line gets executed upon script start, and if it were in the hotkey subroutine, then Time and Count would get reset every time and would not perform the averaging that the comment in his script points out is being performed.

Post Reply

Return to “Ask for Help (v1)”