Page 1 of 1
Help, mGalaxy stays on top??
Posted: Wed Oct 09, 2013 2:29 pm
by PP-Arcade
Hello, first of all I realy love this program! Thanx!
The problem I encounterd is after launching some pc game mGalaxy stays open.
The game does start and I can hear the sounds of the running game.
With alt-tab and select the running game it stays in the background.
I must close mGalaxy to be able to play the game.
I hope this can be fixed somehow
(sorry for the bad english)
Greets PP
Re: Help, mGalaxy stays on top??
Posted: Wed Oct 09, 2013 5:25 pm
by Aeliss
Try with kind of script to test.
Code: Select all
;Parsing
Local $count = StringInStr($CmdLineRaw, ".exe", 0 , 1, 1)
local $app = StringLeft ( $CmdLineRaw, $count + 4 )
local $command = StringTrimLeft( $CmdLineRaw, $count + 4 )
if not $command then exit 0
$PID = Run ('"' & $app & '" ' & $command)
while _WinWaitActivePID($PID)
sleep(500)
wend
WinSetState(_GetHwndFromPID($PID),"",@SW_SHOW)
While ProcessExists ( $PID )
sleep(500)
WEnd
Exit 0
;functions
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
Func _GetHwndFromPID($PID)
$hWnd = 0
$winlist = WinList()
Do
For $i = 1 To $winlist[0][0]
If $winlist[$i][0] <> "" Then
$iPID2 = WinGetProcess($winlist[$i][1])
If $iPID2 = $PID Then
$hWnd = $winlist[$i][1]
ExitLoop
EndIf
EndIf
Next
Until $hWnd <> 0
Return $hWnd
EndFunc;==>_GetHwndFromPID
Re: Help, mGalaxy stays on top??
Posted: Wed Oct 09, 2013 7:25 pm
by PP-Arcade
Hi, thanx for the response.
So I copied the code and compiled it with AutoIt(x86)
Its now "AutoIt.exe", i placed it in the system32 folder (pc games direct to cmd.exe)
Still the same.. Am I doing it right?
Re: Help, mGalaxy stays on top??
Posted: Wed Oct 09, 2013 7:40 pm
by mgalaxy
1) Compile the script
2) Name it "mGalaxy_Script.exe"
3) Put it in the same folder than the application (in your case C:\Windows\System32 or any other folder where you should have copy/paste "cmd.exe" application)
4) In mGalaxy_Runway, verify that, for the chosen system, "Use script file.." is checked.
Re: Help, mGalaxy stays on top??
Posted: Wed Oct 09, 2013 7:47 pm
by PP-Arcade
YES!!
Thanx for the help, it works perfect now.
Greets PP
Re: Help, mGalaxy stays on top??
Posted: Wed Oct 09, 2013 8:00 pm
by PP-Arcade
Oeps, I was to fast.
When closing the game, its stuck, like the script is endless loop.
I checked task manager and the mGalaxy_Script.exe is taking much cpu usage.
I had to end the task for getting the mGalaxy window back.
Re: Help, mGalaxy stays on top??
Posted: Thu Oct 10, 2013 6:06 pm
by Aeliss
Yep sorry was my fault, there was an infinite loop, try this version
Code: Select all
;Parsing
Local $count = StringInStr($CmdLineRaw, ".exe", 0 , 1, 1)
local $app = StringLeft ( $CmdLineRaw, $count + 4 )
local $command = StringTrimLeft( $CmdLineRaw, $count + 4 )
if not $command then exit 0
;Get more info
$count = StringInStr($command, '"', 0 , 1, 1)
local $link = StringTrimLeft ( $command, $count )
$link = StringTrimRight ( $link, 1 )
Local $aDetails = FileGetShortcut($link)
If @error Then exit
local $tmp = StringSplit($aDetails[0], "\")
local $apptorun = $tmp[$tmp[0]]
;run command
$PID = Run ('"' & $app & '" ' & $command)
;wait for application launched
While not(ProcessExists($apptorun))
sleep(500)
WEnd
;try to put in front
WinSetState(_GetHwndFromPID($apptorun),"",@SW_SHOW)
;wait for close
While ProcessExists($apptorun)
sleep(500)
WEnd
;try to resolve bug
;while not(WinActive("mGalaxy.exe"))
; WinActivate("mGalaxy.exe","")
; sleep(100)
;wend
;WinActivate("mGalaxy.exe","")
;WinSetState("mGalaxy.exe","",@SW_SHOW)
Exit 0
;functions
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
Func _GetHwndFromPID($PID)
$hWnd = 0
$winlist = WinList()
;Do
For $i = 1 To $winlist[0][0]
If $winlist[$i][0] <> "" Then
$iPID2 = WinGetProcess($winlist[$i][1])
If $iPID2 = $PID Then
$hWnd = $winlist[$i][1]
;ExitLoop
EndIf
EndIf
Next
;Until $hWnd <> 0
Return $hWnd
EndFunc;==>_GetHwndFromPID
This version is just a beta, sorry, but not enought time to finish it this night, I need to make something to prevent mGalaxy to stay behind when you close the application.
Re: Help, mGalaxy stays on top??
Posted: Thu Oct 10, 2013 6:27 pm
by PP-Arcade
Tested with 3 games, works perfect!!
Thanx for the fast help.
Does it need improvements? (beta?)
Greets PP
Re: Help, mGalaxy stays on top??
Posted: Fri Oct 11, 2013 7:37 pm
by Aeliss
Yep, there is still many bugs ATM, noone of Taito X game are working with it.
This version is bug free, no danger (no infinite loop), it works for all normal game I have installed on my computer.
Code: Select all
;Parsing
Local $count = StringInStr($CmdLineRaw, ".exe", 0 , 1, 1)
local $app = StringLeft ( $CmdLineRaw, $count + 4 )
local $command = StringTrimLeft( $CmdLineRaw, $count + 4 )
if not $command then exit 0
;Get more info
$count = StringInStr($command, '"', 0 , 1, 1)
local $link = StringTrimLeft ( $command, $count )
$link = StringTrimRight ( $link, 1 )
Local $aDetails = FileGetShortcut($link)
If @error Then exit
local $tmp = StringSplit($aDetails[0], "\")
local $apptorun = $tmp[$tmp[0]]
;run command
;Run ('"' & $app & '" ' & $command)
ShellExecute('"' & $link & '"')
;wait for application launched with protection loop
;wait for 5 s and exit if no application found
local $protloop = 10
While not(ProcessExists($apptorun))
$protloop = $protloop - 1
if ($protloop < 0) then exit 0
sleep(500)
WEnd
;try to put in front
local $PID = GetProcessPID($apptorun)
local $WinName = ProcessGetWindow($PID)
WinSetState($WinName,"",@SW_SHOW)
WinSetState($WinName,"",@SW_ENABLE)
;wait for close
While (ProcessExists($apptorun) or (ProcessExists("cmd.exe")))
sleep(500)
WEnd
;try to resolve bug
WinSetState("mGalaxy.exe","",@SW_ENABLE)
Exit 0
;*********************************************************
;functions
;*********************************************************
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
Func GetProcessPID($name)
Local $list = ProcessList($name)
For $i = 1 To $list[0][0]
If $list[$i][0] <> "" then
Return $list[$i][1]
Endif
Next
return 0
endFunc
Func ProcessGetWindow($PId)
If IsNumber($PId) = 0 then
SetError(1)
Else
Local $WinList = WinList()
For $i = 1 To $WinList[0][0]
If WinGetProcess($WinList[$i][0], "") = $PId Then
return $WinList[$i][0]
EndIf
Next
Return 0
EndIf
EndFunc
You can mix the 2 versions or make tries by removing/replacing the ";", I can explain functions if you want to modify the script (only 2/4 functions are used, but I let them for memory)
Re: Help, mGalaxy stays on top??
Posted: Fri Oct 11, 2013 11:19 pm
by PP-Arcade
Tested, works perfect!
[quote="Aeliss"]
You can mix the 2 versions or make tries by removing/replacing the ";", I can explain functions if you want to modify the script (only 2/4 functions are used, but I let them for memory)
[/quote]
I have no knowledge of scripts, so me modifying it is not a good idea lol.
Thanx again, PP
Re: Help, mGalaxy stays on top??
Posted: Sat Oct 12, 2013 2:22 pm
by Aeliss
There is no danger, and I use simple syntax, lot of comment. autoit isn't really difficult.
On the next version mgalaxy will correct a problem when we close the application, so it s better to remove the last line.
Code: Select all
;try to resolve bug
WinSetState("mGalaxy.exe","",@SW_ENABLE)
The last working version I have test is
Code: Select all
;Parsing
Local $count = StringInStr($CmdLineRaw, ".exe", 0 , 1, 1)
local $app = StringLeft ( $CmdLineRaw, $count + 4 )
local $command = StringTrimLeft( $CmdLineRaw, $count + 4 )
if not $command then exit 0
;Get more info
$count = StringInStr($command, '"', 0 , 1, 1)
local $link = StringTrimLeft ( $command, $count )
$link = StringTrimRight ( $link, 1 )
Local $aDetails = FileGetShortcut($link)
If @error Then exit
local $tmp = StringSplit($aDetails[0], "\")
local $apptorun = $tmp[$tmp[0]]
;run command
;Run ('"' & $app & '" ' & $command)
ShellExecute('"' & $link & '"')
;wait for application launched with protection loop
;wait for 5 s and exit if no application found
local $protloop = 10
While not(ProcessExists($apptorun))
$protloop = $protloop - 1
if ($protloop < 0) then exit 0
sleep(500)
WEnd
;try to put in front
local $PID = GetProcessPID($apptorun)
local $WinName = ProcessGetWindow($PID)
WinSetState($WinName,"",@SW_SHOW)
WinSetState($WinName,"",@SW_ENABLE)
;wait for close
While (ProcessExists($apptorun) or (ProcessExists("cmd.exe")))
sleep(500)
WEnd
;To resolve bug in taito Xom Tetris gran master
;local $list = ProcessList("game.exe")
;if $list[0][0] > 0 Then
; local $PID = $list[1][1]
; ProcessWaitClose($PID)
;endif
Exit 0
;*********************************************************
;functions
;*********************************************************
Func GetProcessPID($name)
Local $list = ProcessList($name)
For $i = 1 To $list[0][0]
If $list[$i][0] <> "" then
Return $list[$i][1]
Endif
Next
return 0
endFunc
Func ProcessGetWindow($PId)
If IsNumber($PId) = 0 then
SetError(1)
Else
Local $WinList = WinList()
For $i = 1 To $WinList[0][0]
If WinGetProcess($WinList[$i][0], "") = $PId Then
return $WinList[$i][0]
EndIf
Next
Return 0
EndIf
EndFunc
Re: Help, mGalaxy stays on top??
Posted: Sat Oct 12, 2013 2:43 pm
by PP-Arcade
Thanx man works perfectly.
Greets, PP
Re: Help, mGalaxy stays on top??
Posted: Sun May 25, 2014 9:45 am
by PP-Arcade
Hi, now i have the same problem with the "Playstation Portable" (PPSSPP 0.9.8 for windows)
It runs in the background while mGalaxy stays on top. (I can hear the game launching)
I tried using the same script, that didn't work.
Hope some one can help, greets PP
Re: Help, mGalaxy stays on top??
Posted: Sun May 25, 2014 12:08 pm
by Aeliss
I haven't problem with this app. Are you sure It was in fullscreen mode ?
I m using the official script
Code: Select all
;Parsing
Local $count = StringInStr($CmdLineRaw, ".exe", 0 , 1, 1)
local $app = StringLeft ( $CmdLineRaw, $count + 4 )
local $command = StringTrimLeft( $CmdLineRaw, $count + 4 )
if not $command then exit 0
HotKeySet("{ESC}", "Terminate")
$PID = Run ('"' & $app & '" ' & $command)
While ProcessExists ( $PID )
sleep(500)
WEnd
Exit 0
;functions
Func Terminate()
While ProcessExists ( $PID )
ProcessClose ( $PID )
WEnd
Exit 0
EndFunc
Look in the ppsspp configuration, there is an option like "force ppsspp stay on top"
Or try this script (But I really think it s useless)
Code: Select all
;Parsing
Local $count = StringInStr($CmdLineRaw, ".exe", 0 , 1, 1)
local $app = StringLeft ( $CmdLineRaw, $count + 4 )
local $command = StringTrimLeft( $CmdLineRaw, $count + 4 )
if not $command then exit 0
HotKeySet("{ESC}", "Terminate")
$PID = Run ('"' & $app & '" ' & $command)
while _WinWaitActivePID($PID)
sleep(500)
wend
While ProcessExists ( $PID )
sleep(500)
WEnd
Exit 0
;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
Re: Help, mGalaxy stays on top??
Posted: Sun May 25, 2014 2:02 pm
by PP-Arcade
Hmm I overlooked that "stay on top" option
When in fullscreen press F11 to get that extra option.
Thanx man, works great now! Cheers, PP
(maybe good to include this info on the mGalaxy page "emulator settings")