Jump to content
Sign in to follow this  
iAmNewbe

Mouse Click Delay

Recommended Posts

I have several wireless mouses that the primary left click button seems to become defective and produce multiple left clicks when pressed.  Not sure why but this seems to begin happening after 3 to 4 months and I got tired of buying a new mouse so I delved into the AutoIT manual and wrote with borrowing from the manual the following code that temporarily disables input once the left mouse button is clicked to prevent false double and single clicks from registering.

 

#RequireAdmin

#Region ; Includes
#include <AutoItConstants.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#EndRegion

#Region ; Tray
Opt("TrayMenuMode", 3)   ; Default tray menu items will not be shown.
Opt("TrayOnEventMode", 1)
TraySetClick(16) ; Release Right Mouse Button Show Tray Menu
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "Terminate")
TraySetToolTip("Mouse Click Delay")
#EndRegion

Global $hDLL = DllOpen("user32.dll")

While 1
    If (_IsPressed("1", $hDLL)) Then
        While _IsPressed("1", $hDLL)
            Sleep(10)
        WEnd
        BlockInput(1)
        Sleep(240) ; Amount of Delay between disabling and re-enabling input
        BlockInput(0)
    EndIf
    Sleep(10)
WEnd

Func Terminate()
    DllClose($hDLL)
    Exit 0
EndFunc


I played around with the sleep times to get what seems to work with very little hassle in usability.  There is a minor noticeable delay between pressing the left click button and before being able to move the mouse but anything less and multiple left clicks get registered.  I can now use the collection of mouses that have this issue again.

It would be better if there was a way to disable just the mouse but BlockInput is the only thing available.

I tried setting the MouseclickDelay and also the MouseClickDownDelay Options but they did not work for this issue and the BlockInput did.

Edited by iAmNewbe
Redundant Code Removal

Share this post


Link to post
Share on other sites

Side effect of this code is that Double Clicks do not work.  Not sure what to do about that. 

Edit:
Actually double clicks do work, I just have to adjust my own finger press and slow it down to allow for the delay between clicks set in the code above. Too quick of a click and it is ignored, the code seems to work as designed.
 

Edited by iAmNewbe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...