How to fix failing physical mouse button Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
LeafyWater
Posts: 2
Joined: 16 Apr 2024, 23:21

How to fix failing physical mouse button

Post by LeafyWater » 16 Apr 2024, 23:38

My Mouse Button 5 on my Naga Trinity is failing. While holding the button down, it would randomly release without me physically releasing the button and quickly go back to the held down state. My approach is to have it so that if a release is detected, wait 200 ms while continually sending the button down signal. If after 200 ms the button is still detected as released, stop sending the button down signal. The problem is that my script isn't working. I don't know if it is a problem with the approach or with my implementation. Any help would be appreciated.
Script:

Code: Select all

#Persistent

XButton2::

Send {XButton2 down}
Sleep 10
If (GetKeyState("XButton2","P")=0) {
	Sleep 200
	If (GetKeyState("XButton2","P")=0){
		Send {XButton2 up}
		return
		}
}
return
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
[Mod edit: Moved topic from AHK v2 help since this is v1 code.]

Rohwedder
Posts: 7659
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to fix failing physical mouse button  Topic is solved

Post by Rohwedder » 17 Apr 2024, 01:57

Hallo,
try:

Code: Select all

*XButton2::
Click, X2 Down
Loop {
	KeyWait, XButton2
	KeyWait, XButton2, DT.2
} Until, ErrorLevel
Click, X2 Up
Return

LeafyWater
Posts: 2
Joined: 16 Apr 2024, 23:21

Re: How to fix failing physical mouse button

Post by LeafyWater » 17 Apr 2024, 16:11

Rohwedder wrote:
17 Apr 2024, 01:57
Hallo,
try:

Code: Select all

*XButton2::
Click, X2 Down
Loop {
	KeyWait, XButton2
	KeyWait, XButton2, DT.2
} Until, ErrorLevel
Click, X2 Up
Return
This works, thanks :thumbup:

Post Reply

Return to “Ask for Help (v1)”