OK it looks like you want to toggle the behaviour.
#SingleInstance Force
#installKeybdHook
#Persistent
SetTitleMatchMode, 2 ; Make search title in #IfWinActive more flexible
#IfWinActive, Title of your game as found by AHK Windows Spy
RButton::
If (Toggler := !Toggler )
{
ToolTip, RButton Down
Send, {RButton Down} q
Return
}
ToolTip, RButton Up
Send {RButton Up} q
Return
#IfWinActive
Return
*x::
ExitApp
Update
After reading your text (and ignoring your script where you want to toggle the behaviour), I think that you want this! RightClick
will send RightClick Down + q
, then nothing, until you let go of RightClick
, which will then send a RightClick Up + q
. I added the ToolTips, so you can see if the script is activated correctly by #IfWinActive.
#SingleInstance Force
#installKeybdHook
#Persistent
SetTitleMatchMode, 2 ; Make search title in #IfWinActive more flexible
#IfWinActive, Title of your game as found by AHK Windows Spy
RButton::
ToolTip, RButton Down + q
Send, {RButton Down} q
Return
RButton Up::
ToolTip, RButton Up + q
Send, {RButton Up} q
Return
#IfWinActive
Return
*x::
ExitApp
If this is indeed what you want, then the final solution is coming pretty close to the original tip from Armin!
Update 2, Alternative way
#SingleInstance Force
#installKeybdHook
#Persistent
SetTitleMatchMode, 2 ; Make search title in #IfWinActive more flexible
#IfWinActive, Title of your game as found by AHK Windows Spy
*~RButton:: ; ~ passes Rbutton through
ToolTip, RButton Down + q
Send, q
KeyWait, RButton ; Wait for RButton to be released
ToolTip, RButton Up + q
Send, q
Return
#IfWinActive
Return
*x::
ExitApp