Jump to content
LaunchBox Community Forums

Close custom AHK scripts after a game is closed


peerluk

Recommended Posts

Hi all,

I'm sure somebody has done that already but I didn't find anything in the forums...

I'm using AHK for a couple of games for keymapping. The problem is I need to make sure that the keymapping gets killed after the game is closed.
I know I technically can do that directly in the AHK script but many key mapping scripts can be used on several games. So I'd like to use the same script for many games with as less as possible customization.

So if you have a good, fast to implement on many games, way of doing so. 
Thanks for the advises. 

Link to comment
Share on other sites

I never used RocketLauncher before. Apparently there are very cool features with that.
Speaking of which, do you know about a good Rocket launcher tutorial or is it easy enough to use?

But I believe there must be a very simple way to do what I want. I'll try to add a kill task or something, I just need to figure out a way to trigger the even after the game has closed.

Link to comment
Share on other sites

You'd need to monitor to see if the process is running. I use this to monitor services and if it isn't running, restart it.

; Script Function:
;	Restarts the iTeleportConnect service if it hasn't started - this usually happens if your
;   wireless network interface hasn't started when iTC tries to connect.
;
;   This script loops every (45) seconds to determine if iTC is running or not, and restarts it if it's not.
;

#SingleInstance, force
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

iTC_EXE     = C:\Program Files\iTeleport\iTeleport Connect\iTeleportConnect.exe
iTC_Path    = C:\Program Files\iTeleport\iTeleport Connect
iTC_imgName = iTeleportConnect.exe

loop {
	sleep 45000
	Process, Exist, %iTC_imgName% ; check to see if iTeleportConnect is running
	If (ErrorLevel = 0) ; If it is not running
	   {
	   Run, %iTC_EXE%, %iTC_Path%, hide
	   }
	Else ; If it is running, ErrorLevel equals the process id for the target program (Printkey). Then do nothing.
	   {
		sleep 5
	   }
}

In your case instead of "Run, %iTC_EXE%, %iTC_Path%, hide", use ExitApp to kill the script. This would need to be done for each emulator.

Link to comment
Share on other sites

Hmm, I think I understand what you mean.

So basically add the emulator or windows exe game in the loop. If the process for that game doesn't exit kill ahk.exe?
The problem with that is that I would need to loop every seconds or something like that because if it didn't notice that I exited the game right away, Launchbox wouldn't work correctly for a couple of seconds at least.

I don't know

Link to comment
Share on other sites

It's super powerful and very well-documented. You can learn a lot by looking at tutorials and existing scripts in their forums too. I use it for a lot more day-to-day stuff than just emulation. The backup program at 

 was made with AHK as well.

Link to comment
Share on other sites

@DJQuad

Yes that  IfWinActive seems to do the trick in the platform AHK. I can just specify the game so it doesn't affect anything else but the game it concerns. 

AHK is very cool and super useful for mapping my Arcade cab on many games so far. Street Fighter at the moment!

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...