Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Software fix for double clicking mouse


  • Please log in to reply
25 replies to this topic
Leo Xiong
  • Members
  • 140 posts
  • Last active: Mar 15 2014 06:42 AM
  • Joined: 13 Apr 2010
After using my Logitech M305 mouse for quite a while now, the left mouse button is starting to wear out, and it is beginning to double click something when I try to click once. This was fixed with a simple script to treat double clicks within a certain time frame (800ms worked perfectly for me, you may need to tune it) as a single click.

editIncorrect code :oops:, scroll down for Lexikos' or my new solution.

$LButton::
if(A_TickCount - old < 800) ;increase 800 until the double clicking stops
	Send, {LButton Down}
else
	Send, {LButton Down}
KeyWait, LButton
Send, {LButton Up}
old := A_TickCount

gplus-16.pngLeo Xiong.com
#ahk freenode - catch me there as NameLess-exe!

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Your script doesn't work: both branches of the IF statement perform the same function.

I wrote a similar script for a coworker a while back. The delay can be configured via the tray icon; most of the code is related to that. I hope you don't mind me posting it in your thread. ;)

RegRead minDelay, HKCU, Software\MouseDebouncer, MinDelay
if ErrorLevel
	minDelay := 100  ; Default setting.

#NoTrayIcon  ; Hide initial icon.
Menu Tray, Icon, %A_WinDir%\System32\main.cpl  ; Set icon.
Menu Tray, Icon  ; Show icon.
Menu Tray, NoStandard
Menu Tray, Add, &Configure, TrayConfigure
Menu Tray, Add, E&xit, TrayExit
Menu Tray, Default, &Configure
Menu Tray, Click, 1  ; Single-click to configure.
Menu Tray, Tip, Mouse Debouncer

~LButton::
; Do nothing at all -- click has not been blocked.  This hotkey has
; already achieved its purpose by causing A_PriorHotkey etc to be set.
return

#If A_PriorHotkey != "" && A_TimeSincePriorHotkey < minDelay
LButton::
SoundPlay *-1  ; Play a sound to indicate the click has been blocked.
return

TrayConfigure:
prompt := "Enter the minimum time between clicks, in milliseconds.`n"
		. "Any double-clicks faster than this will be blocked."
Loop
{
	InputBox newMinDelay, Mouse Debouncer, %prompt%,,,,,,,, %minDelay%
	if ErrorLevel  ; Cancelled?
		return
	if (newMinDelay+0 >= 10 && newMinDelay <= 1000)	 ; Valid?
		break
	if (A_Index = 1)
		prompt .= "`n`nPlease enter a number between 10 and 1000."
}
minDelay := newMinDelay
if (minDelay = 100)
	RegDelete HKCU, Software\MouseDebouncer
else
	RegWrite REG_DWORD, HKCU, Software\MouseDebouncer, MinDelay, %minDelay%
return

TrayExit:
ExitApp
AutoHotkey_L required. It can be condensed down to three lines:
~LButton::return  ; Set A_PriorHotkey.
#If A_PriorHotkey != "" && A_TimeSincePriorHotkey < 200
LButton::return  ; Block hotkey.


Leo Xiong
  • Members
  • 140 posts
  • Last active: Mar 15 2014 06:42 AM
  • Joined: 13 Apr 2010

Your script doesn't work: both branches of the IF statement perform the same function.

The if block of code executes if the double click was too fast and treats it as a single click, and the else block is a normal single click.

I hope you don't mind me posting it in your thread. ;)

Not a problem.

AutoHotkey_L required. It can be condensed down to three lines:

~LButton::return  ; Set A_PriorHotkey.
#If A_PriorHotkey != "" && A_TimeSincePriorHotkey < 200
LButton::return  ; Block hotkey.

How about 2 :p? The only thing is it may not work in games and some applications.
LButton::Send, % "{" (A_TimeSincePriorHotkey > 100 ? A_ThisHotkey " Down" : "") "}"
LButton Up::Send, {%A_ThisHotkey%}

gplus-16.pngLeo Xiong.com
#ahk freenode - catch me there as NameLess-exe!

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

The if block of code executes if the double click was too fast and treats it as a single click, and the else block is a normal single click.

This code executes if the double click was too fast:
Send, {LButton Down}
and this code executes if it wasn't:
Send, {LButton Down}
You cannot expect the two branches of the IF statement to have different results when they execute exactly the same code.

I tested your script anyway, and as expected, it didn't work.

Leo Xiong
  • Members
  • 140 posts
  • Last active: Mar 15 2014 06:42 AM
  • Joined: 13 Apr 2010
Whoops :oops:. I was referring to the wrong script. Yep your're right.
gplus-16.pngLeo Xiong.com
#ahk freenode - catch me there as NameLess-exe!

Neewbie
  • Members
  • 7 posts
  • Last active: Dec 21 2012 09:10 PM
  • Joined: 13 Dec 2012

I'm praying some of you are still reading this thread... This script seems to be working rather well compared to the rest of the scripts I've been trying from the forums. Issue is, I have the problem with clickling my middle and right mousebutton. Is there anyway you could modify this script to work for ALL of the mousebuttons? I'm a complete rookie when it comes to the scriptlanguage. 

 

Thanks.



Sjc1000
  • Members
  • 572 posts
  • Last active: Mar 11 2017 11:41 AM
  • Joined: 06 Feb 2012

Hi Neewbie, Welcome to the AutoHotkey forums.

 

You are going to regret that name when you get better smile.png

 

Anyway onto the topic on hand, this code will stop double clicks for all the mouse buttons.

 

 

LButton::
If ( A_TimeSincePriorHotkey > 100 )
Send, {Lbutton Down}
return


Lbutton Up::Send, {Lbutton Up}



MButton::
If ( A_TimeSincePriorHotkey > 100 )
Send, {MButton Down}
return


Mbutton Up::Send, {MButton Up}



RButton::
If ( A_TimeSincePriorHotkey > 100 )
Send, {Rbutton Down}
return


Rbutton Up::Send, {Rbutton Up}


Sjc1000 - Insert inspirational quote here!

PLEASE find me on the IRC if you have questions. I'm never on the forum anymore.

 


Neewbie
  • Members
  • 7 posts
  • Last active: Dec 21 2012 09:10 PM
  • Joined: 13 Dec 2012

Thank you very much Sjc1000, I'll try it out. I've actually had some issues with the former script as it turns out, it doesn't really block out all of the double clicks for whatnot reasons I am not knowledgeable enough to even tip my toes in.

 

But regardless, thanks for your effort, I truly hope this will help as I really am fond of my current mouse (Steelseries Ikari optical gaming mouse).



Neewbie
  • Members
  • 7 posts
  • Last active: Dec 21 2012 09:10 PM
  • Joined: 13 Dec 2012

Oh so I already encountered a problem with your script, it's that it completely blocks out the signal. With the former script it actually still sent through one signals. This is a big issue as I am quite the gamer ;p. Is there perhaps any way to modify that?
 

Truly appreciate your effort, thanks.



Sjc1000
  • Members
  • 572 posts
  • Last active: Mar 11 2017 11:41 AM
  • Joined: 06 Feb 2012

Yes, you are correct it does block the input, but i have tested this more than once so It should still send something :/, are you by any chance using this in a game.. If you are change all the Send's to SendInput.

 

If this still does not work you may have to ask Leo Xiong or Lexikos to modify their script to suit your needs.

 

 

LButton:: If ( A_TimeSincePriorHotkey > 100 ) 
SendInput, {Lbutton Down} 
return 
Lbutton Up::SendInput, {Lbutton Up} 

MButton:: If ( A_TimeSincePriorHotkey > 100 ) 
SendInput, {MButton Down} 
return 
Mbutton Up::SendInput, {MButton Up} 

RButton:: If ( A_TimeSincePriorHotkey > 100 ) 
Send, {Rbutton Down} 
return 
Rbutton Up::SendInput, {Rbutton Up}

Sjc1000 - Insert inspirational quote here!

PLEASE find me on the IRC if you have questions. I'm never on the forum anymore.

 


Neewbie
  • Members
  • 7 posts
  • Last active: Dec 21 2012 09:10 PM
  • Joined: 13 Dec 2012

Hello! So I tried with SendInput  and it still presents with the same problem. It completely ignores the original signal. This makes it extremely hard to play any videogames as sometimes not clicking could deal a huge blow.

I am clicking  a lot.



guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

just post your original script that worked for leftclick, and then we can modify it for the others



Neewbie
  • Members
  • 7 posts
  • Last active: Dec 21 2012 09:10 PM
  • Joined: 13 Dec 2012

The original script is the one Lexikos first submitted above, the wall of text : ). What I did was make 3 different scripts of the same type, just one for every mousebutton. Doing it this way has made the script essentially useless for whatever reason... The script doesn't work at all, I'll try to use the script individually and see if it works, that way we will know whether the scripts are interfering with each other.

 



Neewbie
  • Members
  • 7 posts
  • Last active: Dec 21 2012 09:10 PM
  • Joined: 13 Dec 2012

So I tried the script individually and I keep hearing the sound as it blocks one of the clicks when it doubleclicks. But the thing is... it doesn't even block the doubleclick. I don't know if this is a flaw of the script or it's just me being an utter moron? Help appreciated!
*I'm using Lexikos script btw!

On another sidenote; Sjc1000 script worked just fine when it came to blocking the doubleclicking. But the issue then is that it COMPLETELY blocks the signal so that instead of it doubleclicking it does nothing. This is a big hamstring when gaming!



Neewbie
  • Members
  • 7 posts
  • Last active: Dec 21 2012 09:10 PM
  • Joined: 13 Dec 2012

Ok so I believe I've found the problem! Quite trivial if I may say so myself, I feel kinda dumbfounded. I used Sjc1000 script and what I noticed was that he had typed > 100 which completely blocked out signals above it making it almost literally impossible to click. So I changed those to < 100 but the problem still ocurred bot a lot less frequently but this was due to me clicking extremely much and fast during a gaming session. So I reduced the number to < 50 and voilá! So far so good, posting the modified script!

 

 

LButton:: If ( A_TimeSincePriorHotkey < 50 ) 
SendInput, {Lbutton Down} 
return 
Lbutton Up::SendInput, {Lbutton Up} 
 
MButton:: If ( A_TimeSincePriorHotkey < 50 ) 
SendInput, {MButton Down} 
return 
Mbutton Up::SendInput, {MButton Up} 
 
RButton:: If ( A_TimeSincePriorHotkey < 50 ) 
Sendinput, {Rbutton Down} 
return 
Rbutton Up::SendInput, {Rbutton Up}
 
(I've got no clue how to post as neatly you guys have but hey! gimme a break :D)
Hope this helps for other, I'll keep this topic updated in case I encounter any problems.