Script to Save my Mouse

Get help with using AutoHotkey and its commands and hotkeys
personfaceman

Script to Save my Mouse

19 Apr 2018, 09:52

Thanks in advance.

My mouse is "broken". Its left-click switch lets go occasionally. Whenever it does, it only does it for an incredibly short amount of time, but it still interferes with drag-and-drop things. I know that it is possible to fix this problem with a script, but I don't know how.
swagfag
Posts: 1246
Joined: 11 Jan 2017, 17:59

Re: Script to Save my Mouse

19 Apr 2018, 11:34

i doubt it can be done

get a new mouse or replace the switch
TheVeterinarian

Re: Script to Save my Mouse

19 Apr 2018, 11:34

personfaceman wrote:Thanks in advance.

My mouse is "broken". Its left-click switch lets go occasionally. Whenever it does, it only does it for an incredibly short amount of time, but it still interferes with drag-and-drop things. I know that it is possible to fix this problem with a script, but I don't know how.

Did you try physically cleaning the mouse?

Meantime i'll pray for your mouse
User avatar
evilC
Posts: 4341
Joined: 27 Feb 2014, 12:30

Re: Script to Save my Mouse

19 Apr 2018, 13:05

Yeah, this is probably fixable
However, it will mean delaying all button events for the left mouse button by the amount of time that it glitches out for.
Basically you block all clicks, and wait to see if it re-presses it again within a certain amount of time.
Edit the value of SuppressTime in the script, make it as low as you can whilst still remaining reliable.
If you can get it under 100ms or so, it will probably be pretty much un-noticeable.

Code: Select all

#SingleInstance, force

 ; Change this to alter the max allowed time between a release and re-press
 ; Try to get it as low as possible
SuppressTime := 100 

TimerRunning := 0   ; Is the timer currently running?

; Block LMB press and run this code instead
$*LButton::
    if (TimerRunning){
        ; An up event happened within SuppressTime, and a down event just happened
        ; Cancel the timer
        SetTimerState(0)
        ; Exit so the click just gets blocked
        return
    }
    ; Appears to be a normal press, pass it through
    Send {Blind}{LButton down}
    return

; Block LMB release and run this code instead
$*LButton Up::
    ; Button was released, this may be due to the fault.
    ; The up event has already been blocked, so start a timer running instead
    SetTimerState(1)
    return


; The timer fired before the button was re-held
; Looks like a normal release of the button happened, so send the event now
SendRelease:
    TimerRunning := 0
    Send {Blind}{LButton up}
    return

; Used to turn on and off the timer
SetTimerState(state){
    global TimerRunning, SuppressTime
    TimerRunning := state
    SetTimer, SendRelease, % (state ? "-" SuppressTime : "Off")
}

Return to “Ask For Help”

Who is online

Users browsing this forum: codude, Google [Bot], pneumatic, swagfag and 27 guests