#Requires AutoHotkey v2.0- toggle := False ;initialize the global variable ;the * symbol means run even if modifier buttons are held down (win, ctrl, alt etc.). Usually used for re-mapping keys. *RButton Up:: { if !WinActive("ahk_exe Fallout4.exe") { ;SoundBeep(500) Send "{RButton Up}" Return } Global toggle ;to access and write to the global variable it needs the "Global" keyword If (toggle := !toggle) { Send "{RButton Down}" ;Send "{Click Down Right}" } Else { Send "{RButton Up}" } Return } /* *z:: { ;MsgBox A_AhkVersion Exit } */