Distinguish between single and double click

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

Distinguish between single and double click

10 Feb 2023, 12:52

Hey!
How can I do something like:
- If single click: do A
- If double click: do B and don't do A
I guess the script has to wait the time before deciding if it's double or single, but I can't figure out how to stop it there and then do the detection later.
Thanks!
User avatar
fade2gray
Posts: 85
Joined: 21 Apr 2015, 12:28

Re: Distinguish between single and double click

10 Feb 2023, 13:39

I'm guessing you'd need to determine the double click speed setting somehow.
DoubleClickSpeed.png
DoubleClickSpeed.png (29.23 KiB) Viewed 348 times
hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

Re: Distinguish between single and double press

10 Feb 2023, 17:05

It wasn't really what I indented, sorry for the confusion.

Currently, I use the following in order to detect a double key press:

Code: Select all

If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
The problem with this, is that the script won't "wait" for the double press to happen or not happen, it would just go on forward and execute both the double click if and what comes after.
What I'm looking for is a way to separate the two.

Code: Select all

If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
ToolTip, Double click ; wait to see if it's indeed a double click or not
Else
ToolTip, Single Click ; don't go here in case of double click
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: Distinguish between single and double click

10 Feb 2023, 18:18

You should show the actual script because that’s where the issue probably lies. If your hotkey is defined as ~LButton::, then it’s not going to wait to see if a double-click happens before executing the click.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, peter_ahk and 351 guests