Ok, so I can't explain why, but I think the emul can't be active when you use it with mGalaxy.
Without script, you can listen to the sound, but the emul is hidden
With script, it's locked because it wait for the emul is active to continue >> WinWaitActive("DeSmuME") .
Have you try 'Alt+tab' to make the emul active ?
When I have this problem I m using this code
;functions
Func Terminate()
While ProcessExists ( $PID )
ProcessClose ( $PID )
WEnd
Exit 0
EndFunc
Func _WinWaitActivePID($iPid)
While 1
Local $list = WinList()
For $i = 1 To $list[0][0]
If $list[$i][0] <> "" And IsVisible($list[$i][1]) Then
If WinGetProcess($list[$i][1]) = $iPid AND WinActive($list[$i][1]) Then Return $list[$i][0]
EndIf
Next
WEnd
EndFunc
Func IsVisible($handle)
If BitAND(WinGetState($handle), 2) Then
Return 1
Else
Return 0
EndIf
EndFunc
and use
while _WinWaitActivePID($PID)
sleep(500)
wend
just before WinWaitActive("DeSmuME") .
But after reading it, this code is just waiting too, it don't force the focus, IDK why it works.