I've got an issue with my script. In terms of functionality, it does exactly what I wants most of the time, but unfortunately it isn't 100% consistent.
I am terrible at AHK, so I am likely doing something wrong with syntax
The functionality I wanted out of my script are as follow:
(Note: I've Remapped mouse keys to keyboard keys due to the game not recognizing the script when I used mouse keys)
- XButton1/Mouse Button 4 rebound as key p
- Clicking the RButton sends down key p, then after a short delay sends down key o
- Clicking the RButton also disables Xbutton1, to prevent XButton1 release (= key p release)
- When RButton is released, send o back up. Then, before sending p back up, check if the XButton1 is now being held down as well
- If XButton1 is being held down, remove the disable so that XButton1 release sends p up.
- If XButton1 was not held when the RButton was released, p can be send up
The script accomplishes this, but the issue is that sometimes a RButton press does not seem to send down p+o down correctly, and it only sends down p and gets stuck there. This happens about 1/10 times
This is my current script:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
f12::
Suspend,Toggle
Soundbeep 1000
Return
*LShift::l ; rebind
*LAlt::0 ; rebind
XButton1Disabled := 0
#if XButton1Disabled == 0 ; if not disabled, make mouse button act like p
*XButton1::p
#if XButton1Disabled == 1 ; if disabled, do nothing
*XButton1::return
#if
*RButton::
XButton1Disabled := 1 ; disable side mouse button after clicking the right mouse button
Send {p down}
Sleep, 10
Send {o down}
KeyWait, RButton ; wait until right mouse button is released
Send {o up}
if GetKeyState("XButton1", "p") { ; check if the side button is being held by now
XButton1Disabled := 0 ; if held, lift up the disable and do nothing
return
} else {
Send {p up} ; if not held, send p up and lift the disable afterwards
XButton1Disabled := 0
}
return