Ughh Mouse Clicks Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Ughh Mouse Clicks

25 Nov 2020, 00:55

I've been trying to keep someone from clicking the mouse too fast, but nothing seems to work. Some examples I've seen and used either completely stops the mouse from doing anything even with the computer. It freezes the mouse completely. Then others don't work properly. What happens is if you use the mouse to click a button and then click other buttons, if you do this like 5 or 6 times, it freezes the mouse. Below are some of what I have used. Thank you. I just need for someone not be able to click too fast.

Code: Select all

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

Lbutton Up::Send, {Lbutton Up}

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

Mbutton Up::Send, {MButton Up}

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

Rbutton Up::Send, {Rbutton Up}

Code: Select all

		LButton::
		RButton::
		If (A_PriorHotkey=A_ThisHotkey && A_TimeSincePriorHotkey < 3000)
			return
		Send {%A_ThisHotkey% down}
		KeyWait %A_ThisHotkey%
		Send {%A_ThisHotkey% up}
		Return

Code: Select all

	~Lbutton::
		;400 is the maximum allowed delay (in milliseconds) between presses.
	if (A_PriorHotKey = "~Lbutton" AND A_TimeSincePriorHotkey < 10000)
		Return
	Sleep 10000
	KeyWait, Lbutton
	return
hasantr
Posts: 935
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Ughh Mouse Clicks

25 Nov 2020, 01:09

I had found this but did not have the opportunity to test it.

https://sites.google.com/site/ahkref/tips/fix-false-doubleclicks
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Ughh Mouse Clicks

25 Nov 2020, 01:31

hasantr wrote:
25 Nov 2020, 01:09
I had found this but did not have the opportunity to test it.

https://sites.google.com/site/ahkref/tips/fix-false-doubleclicks
Thank you very much. It doesn't seem to work either :(

If I click three times fast and then move to click another button 3 times fast, it freezes the mouse. I've played with the milliseconds but nothing seems to work for what I need. Thank you! I'm still researching.
hasantr
Posts: 935
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Ughh Mouse Clicks

25 Nov 2020, 02:25

I don't have time to test the codes. Sorry.

But I have a leader. You can put them at the top of your code.

In this way, if A_ThisHotkey or A_PriorHotkey is not LButton, its keys will not be tampered with.
I'm not sure it will work.

Code: Select all

SetBatchLines,-1
LButtonS()
{
	if(A_ThisHotkey == "LButton" ||A_PriorHotkey == "LButton")
		return 1
}
#If LButtonS()
mcl
Posts: 392
Joined: 04 May 2018, 16:35

Re: Ughh Mouse Clicks

25 Nov 2020, 05:44

Try this.

Code: Select all

LockDelay := 500
LButtonLock := False

LButton::
	If (LButtonLock == False) {
		LButtonLock := True
		Send {LButton}
		SetTimer, UnlockLButton, -%LockDelay%
	}
	Return

Lbutton Up::
	Send, {Lbutton Up}
	Return

UnlockLButton:
	LButtonLock := False
	Return
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Ughh Mouse Clicks

25 Nov 2020, 20:06

hasantr wrote:
25 Nov 2020, 02:25
I don't have time to test the codes. Sorry.

But I have a leader. You can put them at the top of your code.

In this way, if A_ThisHotkey or A_PriorHotkey is not LButton, its keys will not be tampered with.
I'm not sure it will work.

Code: Select all

SetBatchLines,-1
LButtonS()
{
	if(A_ThisHotkey == "LButton" ||A_PriorHotkey == "LButton")
		return 1
}
#If LButtonS()
This might be the closest thing that works the best. It allows for clicking somewhat fast and it won't freeze, but if you click really fast it does freeze. Not sure how to solve the really fast clicking, but this is the best working one so far. Thank you, I have put it in the script. Blessings
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Ughh Mouse Clicks

25 Nov 2020, 20:07

mcl wrote:
25 Nov 2020, 05:44
Try this.

Code: Select all

LockDelay := 500
LButtonLock := False

LButton::
	If (LButtonLock == False) {
		LButtonLock := True
		Send {LButton}
		SetTimer, UnlockLButton, -%LockDelay%
	}
	Return

Lbutton Up::
	Send, {Lbutton Up}
	Return

UnlockLButton:
	LButtonLock := False
	Return
Thank you much! This code freezes the mouse completely and I have to stop process in task manager to close program. I adjusted the time a few times, but it always ended with me opening task mgr and ending process that way. Thank you for helping! Blessings.
mcl
Posts: 392
Joined: 04 May 2018, 16:35

Re: Ughh Mouse Clicks

25 Nov 2020, 21:56

What do you mean by 'freeze'? Mouse can't move? Mouse can move, but the buttons don't work?
Are you using the code as a separate script, or as a part of another script, or inside a function?

Also, change Send {LButton} to Send {LButton Down}.
User avatar
mikeyww
Posts: 29376
Joined: 09 Sep 2014, 18:38

Re: Ughh Mouse Clicks  Topic is solved

25 Nov 2020, 22:25

Code: Select all

LButton::
If recent := (A_PriorHotkey = "~LButton Up" && A_TimeSincePriorHotkey < 100) {
 KeyWait, LButton, T.4
 recentAndHeld := ErrorLevel
} Else recentAndHeld := False
Send % (recentAndHeld || !recent) ? "{LButton Down}" : ""
Return

~LButton Up::
If !recentAndHeld && recent
 SoundBeep, 900, 20
Return
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Ughh Mouse Clicks

26 Nov 2020, 03:31

mcl wrote:
25 Nov 2020, 21:56
What do you mean by 'freeze'? Mouse can't move? Mouse can move, but the buttons don't work?
Are you using the code as a separate script, or as a part of another script, or inside a function?

Also, change Send {LButton} to Send {LButton Down}.
Freeze as in the mouse won't perform anymore actions; like hitting the x to close the script or any buttons. It moves but won't click anything. Sorry I didn't explain that better. I did change the Lbutton to Lbutton Down as well. Thank you!
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Ughh Mouse Clicks

26 Nov 2020, 03:32

mikeyww wrote:
25 Nov 2020, 22:25

Code: Select all

LButton::
If recent := (A_PriorHotkey = "~LButton Up" && A_TimeSincePriorHotkey < 100) {
 KeyWait, LButton, T.4
 recentAndHeld := ErrorLevel
} Else recentAndHeld := False
Send % (recentAndHeld || !recent) ? "{LButton Down}" : ""
Return

~LButton Up::
If !recentAndHeld && recent
 SoundBeep, 900, 20
Return
TYTYTY

Blessings

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: conracer, effel, mikeyww and 163 guests