New Update. in case you are not aware, KOF 98 NesicaXLive and KOF 2002 both, at least on my computer, require the 5.1 audio channel to be switch to stereo before running the game or the game will not run correclty. To do this, automatically, I had to create two separate AHK scripts.
THe first one runs the game, makes the appropriate checks, launches another AHK script where it changes the audio to stereo then loads the game. ESC shuts down all process and also switches the audio back to 5.1. This is handy in case you have a HTPC setup like I do and need to make changes for these two titles.
Called for KOF 98 Start_Game_kof.exe. So the AHK would be saved as Start_Game_kof98.ahk
IfExist, .\NesysService.exe
Run, NesysService.exe -app
Sleep, 5000
IfExist, .\cryptserver.exe
Run, cryptserver.exe
Sleep, 10000
Run, D:\Documents\AutoHotKey Scripts\Audio_Channel_Switcher1.1.exe
Sleep, 500
send {F1}
Sleep, 1000
IfExist, .\game kof98.exe
Sleep, 2000
Run, game kof98.exe
Escape::
Process,close,NesysService.exe
Process,close,game kof98.exe
Process,close,cryptserver.exe
Sleep, 1000
Process,WaitClose,NesysService.exe
Process,WaitClose,Game kof98.exe
Sleep 1000
send {F2}
Sleep, 1000
Process,Close,Audio_Channel_Switcher1.1.exe
sleep 500
Process,Close,Start_Game_kof.exe
return
the second code is where the magic happens for the switching. This only works in the instance where your default audio device is listed first.
F1::
Run,Mmsys.cpl
WinWait,Sound
Send,{down}{tab}{enter}
WinWait,Speaker Setup
send {Up 4}{Tab 2}{Enter 3}
Process,close,mmsys.cpl
send {tab}{tab}{Enter 1}
return
F2::
Run,Mmsys.cpl
WinWait,Sound
Send,{down}{tab}{enter}
WinWait,Speaker Setup
send {down 4}{tab}{tab}{Enter 4}
send {tab}{tab}{tab}{Enter 1}
return
Called Audio_Channel_Switcher1.1.exe
Hope it helps.
You may have to edit depending on file location, file names and system audio configuration.