2
votes

My mouse is a little old and started annoying me with double click when I just press one click, then I coded this snippet to block clicks that happens to fast, which works:

lastClick := A_TickCount
LButton::
    ElapsedTime := A_TickCount - lastClick
    If ElapsedTime > 50
        send {LButton}
    Else
        lastClick := A_TickCount
Return

However, now I am unable to drag anything with my mouse.

I'm out of ideas to handle it, I appreciate any ideas. Thanks for your time.

1

1 Answers

0
votes

You're performing your event when the left button is pressed down and when it's released, rather than just when it's released. LButton fires off twice.

When you click and hold, your function detects the downclick and sends off an entire click event, including the release. You want the behaviour to change based on when you are clicking the button down versus releasing it.

This post has more information. Here's their solution:

LButton::  
If (A_TimeSincePriorHotkey < 100) 
   Return
Send {LButton Down}
KeyWait LButton     ;physical state
Send {LButton Up}
Return

You can adjust the wait time as you like.