Jump to content
LaunchBox Community Forums

Running programs before and after a game


Aevans0001

Recommended Posts

Ok so I need to run a program before running a snes game and one after running an snes game.  I know I can manually configure the additional apps to run like this, but I have alot of games.  I tried editing it via notepad ++ but can not find a way to replace due to how the xml is set up. I see that I can add the file just copy and paste, which would be faster than manually editing in launchbox, but still I have a lot of games.  What would make it even better is if I could just load these files whenever I plug in a certain controller, but I don't see how that would be possible.  So what is the best way.

 

Thanks

 

Link to comment
Share on other sites

There is a long work around for this but I dont know if your like it.

 

Im guessing your using retroarch for snes emulation. There is a work around to make a per system autohotkey script in launchbox. What I have done on my setup is...

 

Add a new emulator in LB. 

Named it "Snes retroarch". or whatever

Pointed the path to retroarch.

Bulk edit all or some snes roms to use the newly added emulator.

Obviously it will still be using your normal retroarch but now your have an autohotkey tab in LB just for snes.

 

At this point your gonna have to download and install autohotkey.

Right click on desktop, new, autohotkey script.

Copy and paste the following underneath the other lines.

#SingleInstance, Force
#Persistent
SetTitleMatchMode 2

Run path-to-first-app
Sleep, 2000
 
SetTimer, ProcessCheckTimer, 3000
Return
 
ProcessCheckTimer:
Process, Exist, retroarch.exe
pid1 := ErrorLevel
If (!pid1)
         {
	 Run path-to-second-app
         ExitApp
         }
Return

In this script you have to change "path-to-first-app" and "path-to-second-app".

So the idea with this script is when you execute it, it will run your first app. Then every 3 seconds it checks to see if retroarch is running. If it doesn't find the retroarch process (so after you have exit) it then runs the second app and exits the script.

Save as anything.ahk

Move the script to somewhere you can store it.

Back in LB, edit your new emulator.

In the autohotkey tab put:

Run path-to-new-autohotkey-script.

 

I know iv prob just wasted my time writing this but anyway it should work.

 

Edited by jayjay
Link to comment
Share on other sites

You could give it a try and see how it goes.

 

I stopped using the inbuilt ahk for anything other than simple stuff some time ago. Kept running into issues, cant remember what those issues were, prob my poor coding, like usual. I guess its now become a habit for me not to try with LB ahk.

 

Edit: Im not sure but an issue might be that the script gets closed by LB before it can run the second app. But dont hold me to that.

Edited by jayjay
Link to comment
Share on other sites

Edit 2: If it doesnt work and you dont want to install ahk you could also try creating a new txt file and copy the following:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force
#Persistent
SetTitleMatchMode 2

Run path-to-first-app
Sleep, 2000
 
SetTimer, ProcessCheckTimer, 3000
Return
 
ProcessCheckTimer:
Process, Exist, retroarch.exe
pid1 := ErrorLevel
If (!pid1)
         {
	 Run path-to-second-app
         ExitApp
         }
Return

Change the run path-to-app

Save it as an example "snes script.ahk"

Then go to Launchbox directory and find autohotkey.exe. (Launchbox\Autohotkey\)

Copy and paste a new autohotkey.exe and rename it to "snes script.exe". (it has to match the .ahk file name)

If you place both the .exe and .ahk in the same folder and  then use Launchbox's ahk tab to run it (like in the previous post above). Im sure that should also work.

 

Im also pretty sure using this method makes it portable which is nice for usb drives.

Edited by jayjay
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...