Jump to content
LaunchBox Community Forums

AHK SCRIPT "HOLD JOYSTICK BUTTON TO EXIT EMULATOR"


bman83

Recommended Posts

Hi All,

I am looking for ahk script that will allow me to hold "button 10" on my arcade stick for 5 seconds to exit out of an emulator.

The code below that was submitted in the noob script section will exit on key press only.

 

$joy10:: ; my start button
{
	Process, Close, {{{StartupEXE}}} ;closes emulator
}

 

thanks in advance

bman

Link to comment
Share on other sites

Can try the following:

Go to Launchbox\Autohotkey and change autohotkey to run as admin

EDIT: actually test it with the original script and autohotkey.exe set to run as admin first. Then if that wont work maybe try the following.

 

For dolphin:

$joy10:: ; my start button
{
	keywait, joy10, t5
	if errorlevel <> 0
	{
	Process, Close, Dolphin.exe ;closes emulator
	}
}

 

For ePSXe:

$joy10:: ; my start button
{
	keywait, joy10, t5
	if errorlevel <> 0
	{
	Process, Close, ePSXe.exe ;closes emulator
	}
}

 

For taito... I dont know taito so you will have to add the .exe yourself

$joy10:: ; my start button
{
	keywait, joy10, t5
	if errorlevel <> 0
	{
	Process, Close, taito.exe ;change taito.exe here
	}
}

 

Windows games... Is difficult because of so many .exe. Consider this experimental lol, im not sure how reliable it will be:

$joy10:: ; my start button
{
	keywait, joy10, t5
	if errorlevel <> 0
	{
	WinGetActiveTitle, WindowTitle
	WinGet, PName, ProcessName, %WindowTitle%
	Process, Close, %PName%
	}
}

The idea is... it gets the active window title, uses that title to get the process. Then closes the process.

Again not sure how well any of this will work but anyway have fun.

Edited by jayjay
Link to comment
Share on other sites

Hi JJ,

Firstly thanks very much for your effort and quick replies,

 

$joy10:: ; my start button
{
	keywait, joy10, t5
	if errorlevel <> 0
	{
	WinGetActiveTitle, WindowTitle
	WinGet, PName, ProcessName, %WindowTitle%
	Process, Close, %PName%
	}
}

This code closes windows and taito games since they are both technically the same type of file system

$joy10:: ; my start button
{
	keywait, joy10, t5
	if errorlevel <> 0
	{
	Process, Close, Dolphin.exe ;closes emulator
	}
}

this closes dolphin

epsxe is not closing ?

I will keep trying, although I read somewhere that some applications do not accept these types of commands unless using hooks ?

 

Edited by bman83
update
Link to comment
Share on other sites

I was playing with epsxe and both the scripts above work fine for me. Using hooks etc is beyond me, im not really very good with ahk. Im not sure why it works for me and not you but anyway escape quits epsxe so can try:

$joy10:: ; my start button
{
	keywait, joy10, t5
	if errorlevel <> 0
	{
	Send {esc down}{esc up}
	}
}

This works for me using keyboard buttons and 360 controller.

Link to comment
Share on other sites

Hi JJ

I got this code to work with epsxe

$joy10:: ; my start button
{
	keywait, joy10, t5
	if errorlevel <> 0
	Process, Close, {{{StartupEXE}}} ;closes emulator
}

By putting  the emulator files inside another folder  like this ..Games\Sony Playstation\epsxe\epsxe.exe

Thanks for everything

 

 

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi Jj,

Thanks again for your help using the {esc} up down code worked, had an error in my setup.

In fact this code must be used where {esc} is the exit key used for mame, when getting nvram game files to save upon exiting back to launchbox

 

Link to comment
Share on other sites

  • 5 months later...
On 5/3/2018 at 3:22 AM, bman83 said:

$joy10:: ; my start button

{

keywait, joy10, t5

if errorlevel <> 0

{

WinGetActiveTitle, WindowTitle WinGet, PName, ProcessName, %WindowTitle% Process, Close, %PName%

}

}

I am trying to use this code that bman83 said works to close emulators in windows, but it isn't working for me.

I copied and pasted it into Tools>Edit Autohotkey Script for WIndows Games within Launchbox's menus. I am using a N64 USB controller and I used an ahk script to discover the button numbers for my different buttons on the controller. Button 10 is also my start button, so I just left everything in the script as it was.

I am very new to AHK and am not sure how it is integrated into Launchbox. Do I need to have an ahk file saved in a specific location or do I need to have AHK open at the same time that I am running Launchbox?

Thanks for any help you can provide!

Edited by mdueck
Link to comment
Share on other sites

  • 10 months later...
  • 6 months later...

I want to hold down my select button on my xbox360 wired controller for like maybe 3 seconds max, to exit MAME (arcade64).  Trying to be able to use it in the newest launchbox with hiscore integration.  That integration won't work with rocketlauncher, and since I use that to keymap everything (joy2key), I've never had to figure out any script stuff before since it is all point and click through there.  But I'm trying to just get MAME to work straight through launchbox so I can do the hiscore integration, but don't want to have to reach up to the keyboard to hit esc everytime I need to exit.  Would like to have it on the controller like every other system I have.

Link to comment
Share on other sites

  • 4 months later...

How do i specify this to only one joysticks button? I have a specific exit button on my cab Joy12 however for player 2 it is not an exit button it is actually a Menu button. Also have controllers and if I set it to just Joy12 then whatever is joy12 on the controllers exits the game while playing.. Please advise and thank you for your time in advance!

 

Link to comment
Share on other sites

20 minutes ago, eccocade said:

How do i specify this to only one joysticks button? I have a specific exit button on my cab Joy12 however for player 2 it is not an exit button it is actually a Menu button. Also have controllers and if I set it to just Joy12 then whatever is joy12 on the controllers exits the game while playing.. Please advise and thank you for your time in advance!

 

Hi Eccocade, 

JayJay wrote the scripts for me when I posted.  Maybe you could ask directly and see how you go.

 

 

 

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