Double click when hold down LButton long enough?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
akirofe
Posts: 176
Joined: 05 Apr 2021, 21:54

Double click when hold down LButton long enough?

29 Apr 2024, 05:16

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:
*** Thank you for reading. I am not in coding and know almost nothing about professional coding, hope for your patience and deeply appreciate any of your kind helps. My current interest in this awesome AHK is due to that my work is graphical ((architect/CAD) and, to reduce strains, my right hand is better off not leaving the mouse (an MMO mouse that has 12 side keys which I maps a lot of F keys and other keys in) as much as possible. All the best you lovely coders! ***
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Double click when hold down LButton long enough?

29 Apr 2024, 05:31

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).
akirofe
Posts: 176
Joined: 05 Apr 2021, 21:54

Re: Double click when hold down LButton long enough?

29 Apr 2024, 05:39

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!
*** Thank you for reading. I am not in coding and know almost nothing about professional coding, hope for your patience and deeply appreciate any of your kind helps. My current interest in this awesome AHK is due to that my work is graphical ((architect/CAD) and, to reduce strains, my right hand is better off not leaving the mouse (an MMO mouse that has 12 side keys which I maps a lot of F keys and other keys in) as much as possible. All the best you lovely coders! ***
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Double click when hold down LButton long enough?

29 Apr 2024, 06:00

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.
akirofe
Posts: 176
Joined: 05 Apr 2021, 21:54

Re: Double click when hold down LButton long enough?

29 Apr 2024, 06:19

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...!!
*** Thank you for reading. I am not in coding and know almost nothing about professional coding, hope for your patience and deeply appreciate any of your kind helps. My current interest in this awesome AHK is due to that my work is graphical ((architect/CAD) and, to reduce strains, my right hand is better off not leaving the mouse (an MMO mouse that has 12 side keys which I maps a lot of F keys and other keys in) as much as possible. All the best you lovely coders! ***
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Double click when hold down LButton long enough?

29 Apr 2024, 07:50

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
}
akirofe
Posts: 176
Joined: 05 Apr 2021, 21:54

Re: Double click when hold down LButton long enough?

05 May 2024, 23:11

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?
Attachments
2024-05-06_14h40_31.png
2024-05-06_14h40_31.png (44.69 KiB) Viewed 255 times
*** Thank you for reading. I am not in coding and know almost nothing about professional coding, hope for your patience and deeply appreciate any of your kind helps. My current interest in this awesome AHK is due to that my work is graphical ((architect/CAD) and, to reduce strains, my right hand is better off not leaving the mouse (an MMO mouse that has 12 side keys which I maps a lot of F keys and other keys in) as much as possible. All the best you lovely coders! ***
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Double click when hold down LButton long enough?

06 May 2024, 01:54

If you run a different script, I can’t help troubleshoot it. The script I posted has only 15 lines, not over 150 lines.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Bing [Bot], boardtc, DavidP and 47 guests