Sorry for delayed response Jimmer. Here is what I did. It has been a while since I looked at this, forgive clunky stuff like absolute paths and whatnot. It appears my solution was very specific to the I-Pac, but any USB keyboard encoder that supports macros should work. I just have mine configured so the pause/reset button sends a "P", then an "=".
MAME catches the P and pauses the game. Then this script catches the "=" and if it's depressed for 3 seconds it shuts whatever is running in the foreground down.
I just leave this script constantly running in the background.
; THE I-PAC 4 SENDS A MACRO WITH A "P" AND A "=" WHEN PAUSE/RESET BUTTON IS PRESSED
; MAME AND OTHER GAMES INTERPRET THE "P" AS THE PAUSE SIGNAL
; THIS SCRIPT IGNORES THE "P" AND INSTEAD TIMES HOW LONG THE "=" IS DEPRESSED
; IF "=" IS HELD DOWN FOR OVER 3 SECONDS, THIS SCRIPT EXECUTES A FRONT-END RESET
#WinActivateForce
^!3::Run, C:/CSR/ChangeScreenResolution.exe /d=\\.\DISPLAY1 /w=320 /h=240
^!6::Run, C:/CSR/ChangeScreenResolution.exe /d=\\.\DISPLAY1 /w=640 /h=480
^!8::Run, C:/CSR/ChangeScreenResolution.exe /d=\\.\DISPLAY1 /w=800 /h=600
$=::
; Get Title and ID of current window
WinGetTitle, wTitle, A
wId := WinExist("A")
if (wTitle != "Attract-Mode")
{
KeyWait `=, t3.0
if (errorlevel)
{
; CLOSE OR KILL THE WINDOW THAT WAS ACTIVE WHEN RESET INITIATED
WinClose, ahk_id %wId%,,1.5
IfWinExist, ahk_id %wId%
{
WinKill, ahk_id %wId%
}
; RESET SCREEN RESOLUTION
; USE RUNWAIT
RunWait, C:/CSR/ChangeScreenResolution.exe /d=\\.\DISPLAY1 /w=320 /h=240
; IF ATTRACT-MODE IS RUNNING, BRING IT TO THE FRONT
IfWinExist, Attract-Mode
{
WinActivate
}
; SEND KEYSTROKES TO RESET FOCUS
Send {ALT DOWN}{TAB}{ALT UP}
; IF ATTRACT-MODE IS NOT RUNNING, RESTART IT
IfWinNotExist, Attract-Mode
{
;Run C:\AttractMode\attract.exe
}
; CLOSE ALL AHK SCRIPTS EXCEPT THIS ONE
PID:=DllCall("GetCurrentProcessId")
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where name = 'Autohotkey.exe' and processID <> " PID )
process, close, % process.ProcessId
}
}
Return