View Full Version : hyperlaunch exit wait time
mrchrister
09-30-2010, 03:02 PM
hey guys,
sometimes while playing hyperlaunch exits the game because some people accidently push the exit combo on my x-arcade
is it possible to put a 2 second delay on the exit key combo?
loppydog
10-01-2010, 08:35 PM
Yeah, almost anything is possible if you know how to work with AHK. I am using something similar to this right now, and it works well. With this code you hold the ESC key for 2 seconds and it closes your emulator:
;***********closeprocess WITH ESC kypress***************
CloseProcess:
KeyWait, Esc, T2
if ErrorLevel = 1
{
Hotkey, %exitScriptKey%, Off
Process, Close, %Executable%
Process, WaitClose, %Executable%
Gui, Color, 000000
Gui -Caption +ToolWindow +AlwaysOnTop
Gui, Show, W%A_ScreenWidth% H%A_ScreenHeight%, BlackGui
winactivate, hyperspin.exe
return
}
else
{
Hotkey, %exitEmulatorKey%, Off
send, {Esc}
Hotkey, %exitEmulatorKey%, On
return
;**************************
then in your emulator block you woulds put:
Hotkey, %exitEmulatorKey%, CloseProcess
here is the link to my thread with my hyperlaunch:
http://www.hyperspin-fe.com/forum/showthread.php?t=9678
this will delay hyperlaunch from killing the application
but if aplication has an action on esc key it will be triggered
so for example mame will exit clean saving setting but it would exit
mess also
pj64 will go from full screen to window mode
nestopia will show menu bar or exit (depending on what you configured)
etc
this script will not stop this actions? or it will?
any way to keep from accidentally exiting it is best to have one key that is far away, that is not used in game - like 1P start or 2P start, and combine this with normal keys for esc, tab, enter and so on
you don't want p1 buton 1 and p1 button 2 firing exit
loppydog
10-02-2010, 09:00 AM
on the above script, it would press Esc if the it is not held long enough. but if you do not want a key press of esc just take out his part:
Hotkey, %exitEmulatorKey%, Off
send, {Esc}
Hotkey, %exitEmulatorKey%, On
now nothing will happen if you press Esc for less than two seconds. Also you canchange the amount of time you need to press it by changing "T2" to whatever time you like. The above script is NOT a clean exit, because is just kills the process. There is another more clean script I use as well, but they both work similarly:
ScummvmExit:
KeyWait Esc, t2
Send % Errorlevel ? "!x" : "{Esc}"
KeyWait Esc
Return
In this script, if Esc is held for more than 2 seconds, ALT-X is pressed to cleanly exit ScummVm(notice how I did not use kill process). If it is held for less the Esc key is pressed. This is important for this emulator, as the esc key is use heavily for skipping scenes. You can alter this script to do nothing if the Esc key is held down less than two seconds by changing "{Esc}" to "".
BTW, with this setup, I have never had any issues with accidently exiting an emulator. Also remember, some emualtors/games do not work well with sending keystrokes with AHK...MAME/MESS being an example. but just because you cant send keystrokes to mame, doesnt mean you cant use the "close process method".