iAmNewbe Posted March 21, 2019 Posted March 21, 2019 (edited) 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 March 21, 2019 by iAmNewbe Redundant Code Removal
iAmNewbe Posted March 21, 2019 Author Posted March 21, 2019 (edited) 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 March 21, 2019 by iAmNewbe
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now