I'd like to capture left mouse button clicks and determine if:
- Was it a single click
- Was it a double click (two consecutive clicks during the max. double click time -> DllCall("GetDoubleClickTime"))
- Was it a click and hold (the button wasn't released after clicking it)
The logic of my code is a bit off (it never get's to the double click tooltip) but single clicks and click and hold
is recognized. Click and hold will be used to be able to still select blocks of text. A major problem with click
and hold is that the KeyWait timeout is too long (0.15) so that fast click and holds don't select right from
the position where I clicked... Lowering the timeout (e.g. 0.05) makes the click and hold perfectly accurate but it won't
reach the single click part anymore...
Does anyone have some tips to get all parts working correctly?
Code: Select all
LButton::
mbLeftClicks++
; Check if mouse button get's released immediately
KeyWait, %A_ThisHotkey%, T0.15
if (ErrorLevel = 1) { ; Button is still down -> Click and hold
ToolTip, Click and hold: %mbLeftClicks%
Click down
KeyWait, %A_ThisHotkey%
if (ErrorLevel = 0) { ; Button was released
mbLeftClicks := 0
Click up
}
; Short single / double click(s)
} else {
; Double click
if (mbLeftClicks = 2) {
ToolTip, Double click: %mbLeftClicks%
mbLeftClicks := 0
Click 2
; Single click
} else {
ToolTip, Single click: %mbLeftClicks%
Click
mbLeftClicks--
}
}
return