Master Kenobi-
You have taught me how to fish. I thank you. AutoHotKey is a swell program & this here mechanical engineer re-discovered the joy of simple programming (after I'd re-discovered the joy of making a .CMD file a while back...).
Below is my AutoHotKey file that is in My Documents & that launches when I set C:\Program Files\AutoHotKey\AutoHotKey.exe to be my shell in RegEdit.
Works like a charm. I haven't yet had a MaLa crash to test it, but when I use Windows Task Manager to close MaLa rudely, it behaves as I wish.
This kills many birds with 1 stone: solves my CPWizard-steals-focus-from-MaLa problem, solves my EmuWave-MaLa-plugin-start-and-exit-sounds-get-clipped problem, lets me get back into not loading explorer.exe as my shell, & pops MaLa back up on-screen in the event of a crash (which I haven't yet been able to create on purpose, of course...for me, MaLa often is sensitive to too much mouse/keyboard activity in the first second or so after game exit & MaLa return).
Only one little item that I'd love to be able to implement. As you can see, I have a fun video game "close" sound play upon intentional or unintentional close of MaLa. That works great. But, under normal usage, the user will tap the PC's power button to shut down Windows & the PC altogether. My .AHK script doesn't trigger the fun sound when somebody shuts down the PC. AutoHotKey has a Shutdown command, but that is to trigger a Shutdown, not to detect a shutdown & do something. Any ideas here for some icing to spread upon this tasty cake?
Thanks!

-Learner Jason
; Launch MaLa & CPW, ensure MaLa focus, play random start & end sounds w/out clipping
; launch CPWizard minimized
run, C:\program files\cpwizard\cpwizard.exe -minimized
; generate random #...set high value to # of files in start sound directory, name all files #.wav
random, startsound, 1, 15
; play random start sound
soundplay, c:\emulators\mala\Sound-MaLa_Start\%startsound%.wav, wait
; launch MaLa
run, C:\emulators\mala\mala.exe
; make sure MaLa exists before continuing
winwait, MaLa
; as soon as MaLa loses focus, get it back
winwaitnotactive, MaLa
winactivate, MaLa
;Loop to monitor if MaLa closes
monitormala:
; wait for MaLa to close (intentionally or not)
winwaitclose, MaLa
;Check for MaLa close while holding down Exit Code Key
getkeystate, state, F10
if state = D
{
; generate random #...set 2nd # to # of files in exit sound directory, name all files #.wav
random, exitsound, 1, 11
; play random exit sound
soundplay, c:\emulators\mala\Sound-MaLa_Exit\%exitsound%.wav, wait
; launch Windows Explorer
run, explorer
; exit script
exit
}
;If MaLa exits w/out Exit Code Key...
else
{
; generate random #...set 2nd # to # of files in exit sound directory, name all files #.wav
random, exitsound, 1, 11
; play random exit sound
soundplay, c:\emulators\mala\Sound-MaLa_Exit\%exitsound%.wav, wait
run, C:\emulators\mala\mala.exe
winwait, MaLa
winactivate, MaLa
goto, monitormala
}