Jump to content
LaunchBox Community Forums
bman83

AHK SCRIPT "HOLD JOYSTICK BUTTON TO EXIT EMULATOR"

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

Share this post


Link to post
Share on other sites

Not sure if it will work but can try:

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

 

Edited by jayjay
  • Like 1

Share this post


Link to post
Share on other sites

Works well except for

-  dolphin

- taito x

- windows

 

thanks

Edited by bman83
update

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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
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...