That now works great thank you both! I can exit and close the script using either the Button 12 + 1 combo or offscreen right on the dpad.
Here is the working script just in case it helps anyone else...
#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.
#SingleInstance Force
SetWorkingDir C:\Utils\LaunchBox\Emulators\RPCS3_Lightgun
Process, Exist, Lightgun.exe
If (!ErrorLevel = 0) {
Process,Close,Lightgun.exe
sleep, 1000
}
Run, C:\Utils\Sinden Lightguns\Mouse Mode - RPCS3\Lightgun.exe
Run, C:\Utils\LaunchBox\Emulators\RPCS3_Lightgun\rpcs3.exe C:\Utils\LaunchBox\Emulators\RPCS3_Lightgun\games\BCES01070\PS3_GAME\USRDIR\razingstorm.self --config "C:\Utils\LaunchBox\Emulators\RPCS3_Lightgun\config\custom_configs\config_BCES01070_tcrs.yml", ,Hide
sleep, 1000
Run, C:\Utils\NoMousy\NoMousy.exe /hide ;Hides mouse cursor with NoMousy
Process, WaitClose, rpcs3.exe
ExitRoutine()
;Start Button
$MButton::
{
send {LButton down}
sleep, 60
send {MButton down}
sleep, 20
send {MButton up}
sleep, 60
send {LButton up}
}
Return
$Esc::ExitRoutine()
ExitRoutine()
{
Process,Close,Lightgun.exe
Process,Close,rpcs3.exe
Run,taskkill /im "rpcs3.exe" /F
Run, C:\Utils\NoMousy\NoMousy.exe ;Restores mouse cursor
Sleep, 500
ExitApp
}