Page 1 of 1

Double click when hold down LButton long enough?

Posted: 29 Apr 2024, 05:16
by akirofe
Hi,

Could you please help me with where to read to be able to do a code (or the codes itself... :clap: ) so it will send a double click when I hold down LButton say pass 500ms?

Thank you very much :clap: :clap: :clap:

Re: Double click when hold down LButton long enough?

Posted: 29 Apr 2024, 05:31
by boiler
You need to be more specific on how you want it to work. Do you want the first click to occur immediately upon clicking down then send another click if it’s held down for at least 500 ms? Or do you want it to wait until you release the mouse button before sending anything, then click once if held for less than 500 ms or twice in rapid succession if held for 500 ms or more? If the latter, then normal clicks won’t happen until you release the mouse button instead right when you click down (the normal way).

Re: Double click when hold down LButton long enough?

Posted: 29 Apr 2024, 05:39
by akirofe
Wow thank you Boiler! I didn't think that far... Yes, if held down less than 500ms then a single click is sent when release, and if held down more than 500ms then a (very quick) double click is sent when release - to do a usual "double clicking". Thank you Boiler!

Re: Double click when hold down LButton long enough?

Posted: 29 Apr 2024, 06:00
by boiler
Try this:

Code: Select all

#Requires AutoHotkey v2.0

LButton:: {
	start := A_TickCount
	KeyWait 'LButton'
	if (A_TickCount - start) > 500
		Click
	Click
}

Note that this precludes the ability to drag things with the mouse. That could probably be added if necessary.

Re: Double click when hold down LButton long enough?

Posted: 29 Apr 2024, 06:19
by akirofe
Oh... You are right Boiler...! We still need to exclude the case when the mouse was hold long BUT moved a decent distance (8 (?)) ...? Thank you Boiler...!!

Re: Double click when hold down LButton long enough?

Posted: 29 Apr 2024, 07:50
by boiler
akirofe wrote: Oh... You are right Boiler...! We still need to exclude the case when the mouse was hold long BUT moved a decent distance (8 (?)) ...? Thank you Boiler...!!
This allows you to drag if it is moved more than 8 pixels. However, you can't see it dragging in real time because it has to wait until the mouse is released before it can tell if it was meant to be a drag or a double-click. So it will perform the drag (such as a window moving) without you seeing it happen until you release the mouse button. You can't expect to fundamentally change the way the mouse clicks work and then still have everything behave as if you didn't change it.

Code: Select all

#Requires AutoHotkey v2.0

LButton:: {
	MouseGetPos &px, &py
	start := A_TickCount
	KeyWait 'LButton'
	MouseGetPos &cx, &cy
	if ((A_TickCount - start) > 500)
		if (Abs(cx - px) > 8) || (Abs(cy - py) > 8)
			MouseClickDrag 'L', px, py, cx, cy, 0
		else
			Click 2
	else
			Click
}

Re: Double click when hold down LButton long enough?

Posted: 05 May 2024, 23:11
by akirofe
Thank you very much Boiler!! I didn't know it's that complicated! :o But, it gives me this attached error when run thanks again Boiler?

Re: Double click when hold down LButton long enough?

Posted: 06 May 2024, 01:54
by boiler
If you run a different script, I can’t help troubleshoot it. The script I posted has only 15 lines, not over 150 lines.