Jump to content
LaunchBox Community Forums

Getting a AHK file to work on a specific steam game


nutter1980

Recommended Posts

30 minutes ago, Hamburglin said:

In th ahk scripts for exiting emulators like sega model 2, the code references a variable of the current emulator. It does not literally say "exit segamodel2.exe". 

Somehow, launchbox has a variable stored of the emulator that launched and can access that via ahk in its running script to kill it.

Would be more helpful if you show the script. It is likely just a somewhat generalized AHK that send a close command to the chosen exe used to start the game file. Such as the command below. 

WinClose, ahk_exe {{{StartupEXE}}}

 

Link to comment
Share on other sites

9 minutes ago, Hamburglin said:

Somehow, launchbox has a variable stored of the emulator that launched and can access that via ahk in its running script to kill it.

I believe that to be true because if you try to Google  {{{startup}}} (or however it shows in your other emulators Running Script section) along with 'AutoHotkey', you won't find anything.  But can't say for sure as I didn't write LaunchBox.

The issue with Steam vs. your other emulators is that LaunchBox will start Steam and pass the games ID to it (just like other emus).  And there's probably a 'variable' (PID or whatever) stored for this Steam instance.  But Steam then starts the game (using the ID passed to it) and then closes itself (the referenced PID or Task thread or however that works) while the game continues to play.  Thus LaunchBox sees this as the 'game' (the program it was told to launch in the 1st place) had exited and abandons any reference to that instance.

This assumes you're launching the Steam game via it's ID (seen in the games Launching section) vs. directly to the games exe file.

Also, this is unique to Steam only.  Or, at least, I've never ran across this with any other emulator or platform.

Link to comment
Share on other sites

Yeah, that's it. I'm wondering how launchbox sets that variable and makes it accessible to LB's ahk.

Edit: per your explanation, it can't easily be done for steam games.

I wonder if ahk can be smart enough to go find the process thst was created from a specific steam id.

Edited by Hamburglin
Link to comment
Share on other sites

5 minutes ago, Retro808 said:

Would be more helpful if you show the script. It is likely just a somewhat generalized AHK that send a close command to the chosen exe used to start the game file. Such as the command below. 

WinClose, ahk_exe {{{StartupEXE}}}

 

I'm not sure how ahk would know what the last exe that was started by it would be. But who knows.

Link to comment
Share on other sites

1 hour ago, Hamburglin said:

I wonder if ahk can be smart enough to go find the process thst was created from a specific steam id.

I know the registry holds the value for a "Running" Steam app by its ID.  The registry may hold the related exe for the ID.

Here's a script you can setup as an 'emulator' in LaunchBox and then use to launch your Steam games (via their ID, just like regular Steam does).  It'll launch the game and then wait for the game to exit for exiting itself.   Useful for launching an app before and\or after a Steam game.

You might be able to look in the same registry location to find the running exe.  Maybe. ;) 

;==========================================================
;      Launch before and after a Steam game
;==========================================================
; (1) If using Run Before and Run After, setup the programs/paths below.  
;        ("Edit These Paths")
;     Save this file file somewhere. (i.e. D:\Misc\SteamLaunch.ahk)
;
; (2) Create/Add a new Emulator in LaunchBox
;
; Under Emulator Name:, give it a name.  Something like "SteamLaunch".
; Where it says Emulator Application Path: click Browse and select  
;      ../LaunchBox/ThirdParty/AutoHotkey/AutoHotkey.exe 
; Where it says Default Command-Line Parameters:, type in the full path 
;      to where you saved this file. Put quotes around it!!
;      example:  "D:\Misc\SteamLaunch.ahk"
; Check both boxes:
;       (no quotes, filename only)
; Save this new 'emulator'
;
; (3) Tell the Steam game(s) to Lauch using this Emulator
;       Edit game. Under "Emulation", check "Use an emulator..."
;       Choose the emulator you ceated above
;==========================================================
;==========================================================


;===========================================================
;  Edit These Paths
;===========================================================
runBefore = D:\MyFolder\Utilities\myBeforeApp.exe
runAfter = D:\MyFolder\Utilities\myAfterApp.exe


;===========================================================
; ************** Do Not Edit Below Here ******************
; (except to uncomment the Run Before and/or Run After lines)
;===========================================================

;gets the path to Steam.exe
RegRead, steamLocation, HKCU\Software\Valve\Steam, SteamExe

; Program that runs before starting the Steam game
;Run, %runBefore%

Run, "%steamLocation%" -applaunch %1%

isRunning := "0"
While (isRunning = "0") ; Wait until the game is launched
    RegRead, isRunning, HKCU\Software\Valve\Steam\Apps\%1%, Running
    Sleep, 500

Sleep, 15000

While (isRunning = "1") ; Wait until the game is closed
    RegRead, isRunning, HKCU\Software\Valve\Steam\Apps\%1%, Running
    Sleep, 500


; Program that runs after the Steam game has exited 
;Run, %runAfter%

 

Link to comment
Share on other sites

Awesome. Are you saying that the registry holds the ID -> game.exe name mapping, or the ID -> current runningbprocess name and its PID?

It looks like it's the actual running process data. If that holds the executable name then it's just a matter of figuring out how to kill a process with that name.

If there's no  name, then you'd need to interface with process explorer to see whats running and map those backwards to an ID.

Edited by Hamburglin
Link to comment
Share on other sites

1 hour ago, Hamburglin said:

Awesome. Are you saying that the registry holds the ID -> game.exe name mapping, or the ID -> current runningbprocess name and its PID?

The registry for sure holds the ID (Steam's ID #) for the Running Steam game (as you can see in the script.  The %1% variable).  You'd have to start a Steam game and then open the registry to that path under HKCU and see if there's more info like possibly the exe. It's not going to have the PID.  And the exe may not even be shown.  That's just a guess, and you might get lucky.

You can parse through the Process Explorer's processes, but you won't see anything referencing the ID as that's only a Steam reference.  Process Explorer will only show the actual executable for the game.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...