2013-07-16, 16:12
(2013-07-16, 13:01)lokipoki Wrote:Maybe it will be better to replace Run()/ProcessWait() functions by a simple RunWait(). Suspending XBMC before starting the application will be also better. Also if you change system state (pssuspend) into an If Loop it will be good the revert the state also into the loop. So you script may look something like this :(2013-07-14, 15:45)lokipoki Wrote: Hey.
How do I get back when I close a PC game?!
That`s my code:
Code:#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
Run("D:\HTPC\Programs\autotaskbarhider\TaskBarHider.exe -hide -exit")
_GDIPlus_Startup()
$GUI_Width = @DesktopWidth ;only with these macros other values will result in misplacement of the CD.
$GUI_Height = @DesktopHeight
$hGUI = GUICreate('MyGUI', $GUI_Width, $GUI_Height, 0, 0, $WS_POPUP)
GUICtrlCreatePic('D:\HTPC\Games\PC\screenshot\' & $CmdLine[2] & '.jpg', 0, 0, $GUI_Width, $GUI_Height)
GUISetState()
$hBmp_CD = _GDIPlus_ImageLoadFromFile('D:\HTPC\Games\PC\cartridge\' & $CmdLine[2] & '.png')
$hBmp_Gfx_CD = _GDIPlus_ImageGetGraphicsContext($hBmp_CD)
$iWidth = _GDIPlus_ImageGetWidth($hBmp_CD)
$iHeight = _GDIPlus_ImageGetHeight($hBmp_CD)
$hGUI_Gfx = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBmp = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hBmp_Gfx_CD)
$hBmp_Gfx = _GDIPlus_ImageGetGraphicsContext($hBmp)
$hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrix, $iWidth / 2, $iHeight / 2)
$i = 0
Do
_GDIPlus_MatrixRotate($hMatrix, 3)
_GDIPlus_GraphicsSetTransform($hBmp_Gfx, $hMatrix)
;The CD is not at the Center perfectily, therefore some cliping would occur
_GDIPlus_GraphicsDrawImage($hBmp_Gfx, $hBmp_CD, -$iWidth / 2, -$iHeight / 2)
_GDIPlus_GraphicsDrawImage($hGUI_Gfx, $hBmp, ($GUI_Width / 2) - ($iWidth / 2), ($GUI_Height / 2) - ($iHeight / 2))
_GDIPlus_GraphicsClear($hBmp_Gfx, 0x0000000) ;Make the Background equal to the background of the GUI
Sleep(5)
$i = $i + 1
Until $i = 225
;memory release
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_GraphicsDispose($hBmp_Gfx)
_GDIPlus_GraphicsDispose($hGUI_Gfx)
_GDIPlus_GraphicsDispose($hBmp_Gfx_CD)
_GDIPlus_ImageDispose($hBmp)
_GDIPlus_ImageDispose($hBmp_CD)
_GDIPlus_Shutdown()
If $CmdLine[0] == 2 Then
GUICreate('MyGUI', @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_POPUP, $WS_EX_TOPMOST))
GUISetBkColor(0x000000)
GUISetState()
Run(@ComSpec & " /c " & '"' & $CmdLine[1] & '"', "", @SW_HIDE)
Run("pssuspend XBMC.exe", "", @SW_HIDE)
EndIf
ProcessWait(" ' & $CmdLine[2] & '.exe")
Run ( 'pssuspend -r XBMC.exe')
WinSetState("XBMC","", @SW_MAXIMIZE)
Run("D:\HTPC\Programs\nomousy\nomousy.exe", "", @SW_HIDE)
Run("D:\HTPC\Programs\autotaskbarhider\TaskBarHider.exe -show -exit")
Exit 0
I removed the while loop (refer to code above). But after I close the game the PCLauncher script is still running and XBMC doesn't maximize again. Any Idea whats wrong with my script?
Cheers.
Code:
If $CmdLine[0] == 2 Then
GUICreate('MyGUI', @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_POPUP, $WS_EX_TOPMOST))
GUISetBkColor(0x000000)
GUISetState()
Run("pssuspend XBMC.exe", "", @SW_HIDE)
RunWait(@ComSpec & " /c " & '"' & $CmdLine[1] & '"', "", @SW_HIDE)
Run ( 'pssuspend -r XBMC.exe')
WinSetState("XBMC","", @SW_MAXIMIZE)
Run("D:\HTPC\Programs\nomousy\nomousy.exe", "", @SW_HIDE)
EndIf
Run("D:\HTPC\Programs\autotaskbarhider\TaskBarHider.exe -show -exit")
Exit 0
Concerning the fact that XBMC doesn't maximize again... that a well known old bug of XBMC under Windows. When you send the command to change the state of XBMC from minimized to maximized the state value under windows is effectively changed... but in reality XBMC still appearing minimized (and even if for Windows it is maximized). The way you can bypass it is to play with the launcher toggle windows state advanced options into Advanced Launcher and/or the window/true fullscreen mode under XBMC video settings. There is no really rules how make it works correctly.