Author Topic: Help, mGalaxy stays on top??  (Read 12362 times)

PP-Arcade

  • Newbie
  • *
  • Posts: 43
Re: Help, mGalaxy stays on top??
« Reply #15 on: May 25, 2014, 09:02:50 AM »
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")
« Last Edit: May 25, 2014, 09:20:26 AM by PP-Arcade »

Aeliss

  • Hero Member
  • *****
  • Posts: 915
Re: Help, mGalaxy stays on top??
« Reply #14 on: May 25, 2014, 07:08:35 AM »
I haven't problem with this app. Are you sure It was in fullscreen mode ?

I m using the official script

Code: (autoit) [Select]
;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: (autoit) [Select]
;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

« Last Edit: May 25, 2014, 07:17:28 AM by Aeliss »

PP-Arcade

  • Newbie
  • *
  • Posts: 43
Re: Help, mGalaxy stays on top??
« Reply #13 on: May 25, 2014, 04:45:11 AM »
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 8)
« Last Edit: May 25, 2014, 05:06:50 AM by PP-Arcade »

PP-Arcade

  • Newbie
  • *
  • Posts: 43
Re: Help, mGalaxy stays on top??
« Reply #12 on: October 12, 2013, 09:43:41 AM »
Thanx man works perfectly.  :D

Greets, PP

Aeliss

  • Hero Member
  • *****
  • Posts: 915
Re: Help, mGalaxy stays on top??
« Reply #11 on: October 12, 2013, 09:22:24 AM »
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]
;try to resolve bug
WinSetState("mGalaxy.exe","",@SW_ENABLE)

The last working version I have test is

Code: (autoit) [Select]
;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

PP-Arcade

  • Newbie
  • *
  • Posts: 43
Re: Help, mGalaxy stays on top??
« Reply #10 on: October 11, 2013, 06:19:32 PM »
Tested, works perfect!  :D

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)

I have no knowledge of scripts, so me modifying it is not a good idea lol.

Thanx again, PP

Aeliss

  • Hero Member
  • *****
  • Posts: 915
Re: Help, mGalaxy stays on top??
« Reply #9 on: October 11, 2013, 02:37:32 PM »
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: (autoit) [Select]
;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)
« Last Edit: October 11, 2013, 02:53:51 PM by Aeliss »

PP-Arcade

  • Newbie
  • *
  • Posts: 43
Re: Help, mGalaxy stays on top??
« Reply #8 on: October 10, 2013, 01:27:11 PM »
Tested with 3 games, works perfect!!

Thanx for the fast help.

Does it need improvements? (beta?)

Greets PP

Aeliss

  • Hero Member
  • *****
  • Posts: 915
Re: Help, mGalaxy stays on top??
« Reply #7 on: October 10, 2013, 01:06:15 PM »
Yep sorry was my fault, there was an infinite loop, try this version

Code: (autoit) [Select]
;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.

PP-Arcade

  • Newbie
  • *
  • Posts: 43
Re: Help, mGalaxy stays on top??
« Reply #6 on: October 09, 2013, 03:00:04 PM »
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.

PP-Arcade

  • Newbie
  • *
  • Posts: 43
Re: Help, mGalaxy stays on top??
« Reply #5 on: October 09, 2013, 02:47:53 PM »
YES!!

Thanx for the help, it works perfect now.

Greets PP  8)

mgalaxy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1168
    • Email
Re: Help, mGalaxy stays on top??
« Reply #4 on: October 09, 2013, 02:40:10 PM »
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.

PP-Arcade

  • Newbie
  • *
  • Posts: 43
Re: Help, mGalaxy stays on top??
« Reply #3 on: October 09, 2013, 02:25:50 PM »
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?  ???

Aeliss

  • Hero Member
  • *****
  • Posts: 915
Re: Help, mGalaxy stays on top??
« Reply #2 on: October 09, 2013, 12:25:27 PM »
Try with kind of script to test.

Code: (autoit) [Select]
    ;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

« Last Edit: October 09, 2013, 12:35:08 PM by Aeliss »

PP-Arcade

  • Newbie
  • *
  • Posts: 43
Help, mGalaxy stays on top??
« Reply #1 on: October 09, 2013, 09:29:34 AM »
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  :D  (sorry for the bad english)

Greets PP