2013-08-12, 08:23
I remade my steam script, it allows ALA to launch steam games.
- it will track if steam is open and if it was it will not close it after closing the game
- it will let you pause xbmc once the game starts
- it will resume xbmc when the game is done
I'm looking for a way to print a toaster popup on XBMC itself when an error occurs but this is not implemented yet. I will also add a parameter to force shutdown steam even if it was open before starting the script
You can call it like this:
Will launch steam game with id 20800 and will pause XBMC
Will launch steam game with id 20800 and will not pause XBMC
Will launch steam game with id 20800 and will not pause XBMC
You need sysinternals suite in your path, to makes things easy you can extract them in c:\windows
- it will track if steam is open and if it was it will not close it after closing the game
- it will let you pause xbmc once the game starts
- it will resume xbmc when the game is done
I'm looking for a way to print a toaster popup on XBMC itself when an error occurs but this is not implemented yet. I will also add a parameter to force shutdown steam even if it was open before starting the script
You can call it like this:
Code:
launcher_steam 20800 TRUE
Code:
launcher_steam 20800 FALSE
Code:
launcher_steam 20800
You need sysinternals suite in your path, to makes things easy you can extract them in c:\windows
Code:
@echo off
REM usage:
REM call launcher_steam with an argument that is the steamid of the game
REM ex: launcher_steam 40800
REM script will track for gameoverlayui.exe
REM global variables
REM the process that must be tracked
set process_1=gameoverlayui.exe
REM steam process
set process_2=steam.exe
REM process to be paused
set process_3=xbmc.exe
REM don't touch this
set ignore_result=INFO:
REM initialize iteration
set iteration=0
REM if second argument is true it will pause process_3 while process_1 is running
IF "%2"=="" (
set PAUSE=FALSE
) ELSE (
IF "%2"=="TRUE" (
set PAUSE=TRUE
) ELSE (
set PAUSE=FALSE
)
)
set STEAMSTATE=STOPPED
set GAMESTATE=STOPPED
set LAUNCHERSTATE=INITIALIZING
echo pause %process_3%: %PAUSE%
echo --
echo --
:CHECKSTEAM
echo --
if %LAUNCHERSTATE%==INITIALIZING set limit=5
if %LAUNCHERSTATE%==STARTSTEAM set limit=60
echo check if steam is running
echo -----------------------------------------------------------------
set iteration=0
set interval=1
set limit=10
echo launcher status: %LAUNCHERSTATE%
echo steam status: %STEAMSTATE%
echo game status: %GAMESTATE%
:0
set var=NOT_RUNNING
for /f "usebackq" %%A in (`tasklist /nh /fi "imagename eq %process_2%"`) do if not %%A==%ignore_result% set var=RUNNING
echo waiting...
set /a iteration=iteration+1
timeout %interval% > null
IF %var% == NOT_RUNNING (
IF %LAUNCHERSTATE%==INITIALIZING (
set LAUNCHERSTATE=STARTSTEAM
goto :LAUNCH
)
IF %LAUNCHERSTATE%==STARTSTEAM (
if %iteration%==%limit% goto :FAILURE
goto :0
)
IF %LAUNCHERSTATE%==STOPSTEAM (
set STEAMSTATE=STOPPED
goto :EXIT
)
)
IF %var% == RUNNING (
IF %LAUNCHERSTATE%==INITIALIZING (
set STEAMSTATE=ALREADYRUNNING
set LAUNCHERSTATE=STARTINGGAME
goto :LAUNCH
)
IF %LAUNCHERSTATE%==STARTSTEAM (
IF %STEAMSTATE%==STOPPED set STEAMSTATE=STARTED
set LAUNCHERSTATE=STARTINGGAME
goto :CHECKGAME
)
IF %LAUNCHERSTATE%==STOPSTEAM (
if %iteration%==%limit% goto :FAILURE
goto :0
)
)
exit /B
:CHECKGAME
echo --
echo check if game is running
echo -----------------------------------------------------------------
set iteration=0
set limit=60
IF %LAUNCHERSTATE% == STARTINGGAME (
set interval=1
)
IF %LAUNCHERSTATE% == WAITING (
set interval=10
)
echo launcher status: %LAUNCHERSTATE%
echo steam status: %STEAMSTATE%
echo game status: %GAMESTATE%
:1
set var=NOT_RUNNING
for /f "usebackq" %%A in (`tasklist /nh /fi "imagename eq %process_1%"`) do if not %%A==%ignore_result% set var=RUNNING
echo waiting...
set /a iteration=iteration+1
timeout %interval% > null
IF %var% == NOT_RUNNING (
IF %LAUNCHERSTATE% == STARTINGGAME (
if %iteration%==%limit% goto :FAILURE
goto :1
)
IF %LAUNCHERSTATE% == WAITING (
SET LAUNCHERSTATE=STOPSTEAM
SET GAMESTATE=STOPPED
goto :STOP
)
)
IF %var% == RUNNING (
IF %LAUNCHERSTATE% == STARTINGGAME (
SET LAUNCHERSTATE=WAITING
SET GAMESTATE=STARTED
if %PAUSE%==TRUE (
echo pausing %process_3%
pssuspend %process_3%
)
goto :CHECKGAME
)
IF %LAUNCHERSTATE% == WAITING (
goto :1
)
)
exit /B
:LAUNCH
echo --
echo call launcher
echo -----------------------------------------------------------------
set iteration=0
set interval=1
set limit=60
echo launcher status: %LAUNCHERSTATE%
echo steam status: %STEAMSTATE%
echo game status: %GAMESTATE%
start "GAME" "steam://rungameid/"%1
echo waiting...
set /a iteration=iteration+1
timeout %interval% > null
IF %STEAMSTATE%==ALREADYRUNNING (
goto :CHECKGAME
)
IF %STEAMSTATE%==STOPPED (
goto :CHECKSTEAM
)
exit /B
:STOP
echo --
echo stopping launcher
echo -----------------------------------------------------------------
set iteration=0
set interval=1
set limit=60
echo launcher status: %LAUNCHERSTATE%
echo steam status: %STEAMSTATE%
echo game status: %GAMESTATE%
if %PAUSE%==TRUE (
echo unpausing %process_3%
pssuspend -r %process_3%
)
IF %STEAMSTATE%==ALREADYRUNNING (
set STEAMSTATE=WONTSTOP
goto :EXIT
)
IF %STEAMSTATE%==STARTED (
start C:\Games\steam\steam.exe -shutdown
echo waiting...
set /a iteration=iteration+1
timeout %interval% > null
goto :CHECKSTEAM
)
echo waiting...
:EXIT
echo --
echo cleanup
echo -----------------------------------------------------------------
set iteration=0
set interval=1
set limit=60
echo launcher status: %LAUNCHERSTATE%
echo steam status: %STEAMSTATE%
echo game status: %GAMESTATE%
echo done..
exit /B
:FAILURE
echo FAILURE %LAUNCHERSTATE%
exit /B