Howdy-
Loadman asked me to share my solution for my loss of focus problem, which still persists today when I don't use the following AutoHotKey script.
I actually have 2 AHK scripts that run (copied & pasted below--BYOAC won't let me attach a .ahk file).
AutoHotKey.ahk launches when my PC boots. The first thing it does is launch the shutdownmonitor.ahk script.
AutoHotKey.ahk launches CPWizard & then plays a random sound from a directory
It then launches MaLa, waits to be sure that MaLa is launched, pauses 10 seconds, then clicks the left mouse button, then waits for MaLa to close.
When MaLa closes, it plays another random sound.
if I'm holding down a secret key on my control panel, it will exit to Windows. If the secret key is not held down (i.e., MaLa crashed or somebody stumbled across the exit menu if I forgot to disable it), MaLa will relaunch immediately.
The other script, shutdownmonitor.ahk, waits for the PC power button to be pressed, then plays a random sound, then executes the shutdown.
I hope these are of help to others with the loss of focus problem or who might have other issues or might want to spice up their cabinet with some random sounds.
Thanks,
-Jason
AutoHotkey.ahk:
; Launch MaLa & CPW, ensure MaLa focus, play random start & end sounds w/out clipping
; run shutdown monitor script
run, C:\Documents and Settings\Customer\My Documents\shutdownmonitor.ahk
; 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, 20
; play random start sound
soundplay, c:\emulators\mala\Sound-MaLa_Start\%startsound%.wav, wait
;Loop to launch MaLa & monitor if MaLa closes
monitormala:
; 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
;sleep, 1000 ; had to have a short pause here or regaining focus wouldn't work...
;winwaitnotactive, MaLa
;winactivate, MaLa
sleep, 10000
click
; 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, 16
; 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
goto, monitormala
}
shutdownmonitor.ahk:
#singleinstance ignore
OnMessage(0x11, "powerbutton")
Return
powerbutton(wParam, lParam)
{
SetTimer, soundoff, -10
Return false ; abort shutdown
}
soundoff:
; generate random #...set 2nd # to # of files in exit sound directory, name all files #.wav
random, exitsound, 1, 16
; play random exit sound
soundplay, c:\emulators\mala\Sound-MaLa_Exit\%exitsound%.wav, wait
Shutdown,5
Return