Originally Posted by
thebbandit
I wrote a batch script that will launch Path of exile, alongside some other scripts I have running alongside POE. I know this in itself is not very special, but this batchfile actually checks first if the game or scripts are open and it will not re-launch a new instance of the files.
Store the batch file somewhere it can stay (filename.bat), then make a shortcut to the batch file on your desktop. Select properties and then launch minimized. Now when you run the batch file it will check if the game is open, and check if all your scripts are open.
There are REMarks in the batch file to help make modifications. It is set up to launch WingmanReloaded, TradeMacro and Trades Companion but this should work for any type of script or program. Just launching the game does not require AHK, everything in the Scripts Section will require that AHK is installed.
Code:
SETLOCAL
ECHO OFF
SET run_as=C:\Windows\System32\runas.exe
REM Name of the local user account you are having launch the EXE
SET local_user=ReplaceWithUserName
REM Possible EXE names: PathOfExile.exe, PathOfExile_x64.exe, PathOfExileSteam.exe, PathOfExile_x64Steam.exe, PathOfExile_KG.exe, PathOfExile_x64_KG.exe
SET exe_name=PathOfExile_x64.exe
REM You can launch the game with additional Parameters
SET exe_params=--nologo --waitforpreload
REM Keep in mind because of strange reasons this one must have / instead of \
SET exe_path=C:/Program Files (x86)/Grinding Gear Games/Path of Exile/
REM Make sure to change this drive letter if not on C: drive
CD C:
TASKLIST /fi "IMAGENAME eq %exe_name%" 2>NUL | FIND /I /N "%exe_name%">NUL
IF NOT "%ERRORLEVEL%"=="0" START %run_as% /user:%local_user% /savecred "cmd /C cd \"%exe_path%\" && Start /high %exe_name% %exe_params%"
REM ---------------
REM Scripts Section
REM ---------------
REM Place all scripts in subfolders one directory
SET scripts_path=C:\Path\To\The\Path of Exile\Scripts
REM Name of the script to run
SET script_1_name=PoE-Wingman.ahk
REM Which subdirectory of the scripts folder
SET script_1_subpath=WingmanReloaded
REM What to look for as an active process in AHK
SET script_1_searchString=PoE-Wingman.ahk ahk_exe AutoHotkey.exe
REM Build the Path from supplied values
SET script_1_path=%scripts_path%\%script_1_subpath%\%script_1_name%
REM Script 2
SET script_2_name=Run_TradeMacro.ahk
SET script_2_subpath=POE-TradeMacro
SET script_2_searchString=_TradeMacroMain.ahk ahk_exe AutoHotkey.exe
REM Build the Path
SET script_2_path=%scripts_path%\%script_2_subpath%\%script_2_name%
REM Script 3
SET script_3_name=POE Trades Companion.ahk
SET script_3_subpath=POE-Trades Companion
SET script_3_searchString=%script_3_name% ahk_exe AutoHotkey.exe
REM Build the Path
SET script_3_path=%scripts_path%\%script_3_subpath%\%script_3_name%
REM Send script to AutoHotkey to evaluate for hidden window titles
(
ECHO #NoTrayIcon
ECHO SetTitleMatchMode, 2
ECHO DetectHiddenWindows On
ECHO If !WinExist^("%script_1_searchString%"^^^)
ECHO Run %script_1_path%
ECHO If !WinExist^("%script_2_searchString%"^^^)
ECHO Run %script_2_path%
ECHO If !WinExist^("%script_3_searchString%"^^^)
ECHO Run %script_3_path%
ECHO ExitApp
)| AutoHotkey.exe *
Thanks for this!
The first part is working great, but the script part is acting weird I think?
I guess its supposed to check if the tools/scripts are running and if not then start, right?
For me its only opening the tools/scripts folder without running them.
Code:
SET scripts_path="C:\Users\USER\Documents\Gaming Tools\Path of Exile"
On this folder I have all the PoE Tools and Scripts within subfolder, so Wingman is under:
Code:
"C:\Users\USER\Documents\Gaming Tools\Path of Exile\WingmanReloaded"
After executing the batch file the windows explorer opens to the folder and marks the WingmanReloaded folder, but its not executing it.
Whole script section:
Code:
REM ---------------
REM Scripts Section
REM ---------------
REM Place all scripts in subfolders one directory
SET scripts_path="C:\Users\USER\Documents\Gaming Tools\Path of Exile"
REM Name of the script to run
SET script_1_name=PoE-Wingman.ahk
REM Which subdirectory of the scripts folder
SET script_1_subpath=WingmanReloaded
REM What to look for as an active process in AHK
SET script_1_searchString=PoE-Wingman.ahk ahk_exe AutoHotkey.exe
REM Build the Path from supplied values
SET script_1_path=%scripts_path%\%script_1_subpath%\%script_1_name%
REM Script 2
SET script_2_name=TraderForPoe.exe
SET script_2_subpath=POE-TradeMacro
SET script_2_searchString=_TradeMacroMain.ahk ahk_exe AutoHotkey.exe
REM Build the Path
SET script_2_path=%scripts_path%\%script_2_name%
REM Send script to AutoHotkey to evaluate for hidden window titles
(
ECHO #NoTrayIcon
ECHO SetTitleMatchMode, 2
ECHO DetectHiddenWindows On
ECHO If !WinExist^("%script_1_searchString%"^^^)
ECHO Run %script_1_path%
ECHO If !WinExist^("%script_2_searchString%"^^^)
ECHO Run %script_2_path%
ECHO ExitApp
)| AutoHotkey.exe *
PS: TraderForPoe.exe works fine, its just wingman wont open up.