bman83 Posted May 2, 2018 Share Posted May 2, 2018 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 Quote Link to comment Share on other sites More sharing options...
jayjay Posted May 2, 2018 Share Posted May 2, 2018 (edited) 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 May 2, 2018 by jayjay 1 Quote Link to comment Share on other sites More sharing options...
bman83 Posted May 2, 2018 Author Share Posted May 2, 2018 Thanks for your quick reply JJ, I will try this today, fingers crossed 1 Quote Link to comment Share on other sites More sharing options...
bman83 Posted May 3, 2018 Author Share Posted May 3, 2018 (edited) Works well except for - dolphin - taito x - windows thanks Edited May 6, 2018 by bman83 update Quote Link to comment Share on other sites More sharing options...
jayjay Posted May 3, 2018 Share Posted May 3, 2018 (edited) 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 May 3, 2018 by jayjay Quote Link to comment Share on other sites More sharing options...
bman83 Posted May 3, 2018 Author Share Posted May 3, 2018 (edited) 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 May 3, 2018 by bman83 update Quote Link to comment Share on other sites More sharing options...
jayjay Posted May 3, 2018 Share Posted May 3, 2018 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. Quote Link to comment Share on other sites More sharing options...
bman83 Posted May 6, 2018 Author Share Posted May 6, 2018 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 1 Quote Link to comment Share on other sites More sharing options...
bman83 Posted May 15, 2018 Author Share Posted May 15, 2018 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 Quote Link to comment Share on other sites More sharing options...
mdueck Posted November 3, 2018 Share Posted November 3, 2018 (edited) 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 November 3, 2018 by mdueck Quote Link to comment Share on other sites More sharing options...
cleverest Posted September 24, 2019 Share Posted September 24, 2019 Thank you for this! 1 Quote Link to comment Share on other sites More sharing options...
damageinc86 Posted April 14, 2020 Share Posted April 14, 2020 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. Quote Link to comment Share on other sites More sharing options...
eccocade Posted August 21, 2020 Share Posted August 21, 2020 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! Quote Link to comment Share on other sites More sharing options...
bman83 Posted August 21, 2020 Author Share Posted August 21, 2020 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. Quote Link to comment Share on other sites More sharing options...
eccocade Posted August 21, 2020 Share Posted August 21, 2020 maybe i can use jamma 0-1 16777227 with ahk??? Quote Link to comment Share on other sites More sharing options...
bman83 Posted August 21, 2020 Author Share Posted August 21, 2020 Hi Ecco, What if you set both buttons to "MENU" and set the ahk to "EXIT EMULATOR" if you hold the button for 5 seconds or so. That way both functions should work. As in my example I used start. And Hold start to exit. cheers Bman Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.