View Full Version : Multiple Exit Keys
DillonFoulds
08-25-2011, 06:40 AM
I'd like to change my hyperlaunch script to have exitemulatorkey be EITHER (NOT BOTH) Escape or Joy11.
I use hyperspin in my htpc, and I have a logitech harmony remote that has Exit set to escape. Also I have a pair of PS3 controllers, and the Playstation button is mapped to "Joy11".
Individually, I can use "ExitEmulatorkey = Esc" or "ExitEmulatorkey = Joy11" and they work fine, but I'd like to be able to use -either- button to exit emulators (again, not BOTH buttons pushed at the same time, but just either button).
Is this even possible?
Not possible with one hotkey but you can add another hotkey command and recompile ahk
DillonFoulds
09-05-2011, 09:40 PM
As per your advice, I created a line "exitEmulatorJoy = Joy11" directly underneath "exitemulatorkey = Esc", and for every emulator in hyperspin I added a second line:
Hotkey, %exitemulatorjoy%, CloseProcess
This worked a treat, now I can successfully exit emulators from Keyboard, Joystick, and Harmony Remote with "Exit" programmed to Escape. :D
I'm still going to play with this a little bit. I'm surprised there's no OR or even a double pipe (||) as an operator for hotkeys, when there is a & command.
Great, good job.
For using OR or || in hotkeys you can check ahk home page, I looked but didn't find anything.
DillonFoulds
09-06-2011, 10:30 AM
Maybe when I get home this evening, I'll test out something like...
ExitEmulatorKey = ( Esc || Joy11 )
... and see if hyperlaunch even loads still. I stole this idea from the dual emulators per console idea.
DillonFoulds
09-15-2011, 08:50 PM
A quick follow up, the double pipes (||, not my arms) and the "OR" did NOT work, and instead threw errors out when launching hyperlaunch.
At this point the only two options i can try are the ExitEmulatorJoy (confirmed working) or setting a dual variable option like...
joy11::
escape::
(exit code)
return
The only issue with this, is that exitemulatorkey as a hotkey is defined in -every- emulator section in hyperlaunch, thus greatly increasing the size of the script (not a big problem, but not the best way to handle things).
Is there some reason that exitemulatorkey is defined in every section, and not just once at the top of the script? Is it just a failsafe for the systems that like using set buttons, wherein an exit key may accidentally be pressed (IE: the Q button perhaps on an emulator that uses a full keyboard layout)?
DillonFoulds
09-24-2011, 08:35 AM
As a final followup to this, I had a chance to really go through HyperLaunch a bit of the last couple days.
1. Define both Keyboard and joystick hotkeys under the "Main Settings" section.
exitEmulatorKey = Esc ;These keys/key combos will close any emulators
exitEmulatorJoy = Joy11 ;that do not have normal closing methods.
2. Added the hotkeys for exit to the "Get Parameters and Set Hotkeys" Section. It now looks as follows:
;----------------------------------------------------------------------------;
; GET PARAMATERS AND SET HOTKEYS ;
;----------------------------------------------------------------------------;
if 0 < 2
{
MsgBox Usage: HyperLaunch.ahk/exe "System Name" "Rom Name"
ExitApp
}
systemName = %1%
romName = %2%
Hotkey, %exitScriptKey%, ExitScript
if (hideCursor = "true")
{
Hotkey, %toggleCursorKey%, ToggleCursor
SystemCursor("Off")
}
Hotkey, %exitEmulatorKey%, CloseProcess
Hotkey, %exitEmulatorJoy%, CloseProcess
WinClose, cmd.exe
3. Now in any hyperlaunch subsections (in my case, only Pop-Cap games) that require use of your hotkeys in the external programs/emulators (Ie: Esc opens menu, but it's my %exitEmulatorKey%) we need to disable the hotkeys. So now it looks like this:
;*****PopCap*****
else if (systemName = "Pop Cap" && executable = "PCLauncher.exe")
{
hideDesktop()
Hotkey, %exitEmulatorKey%, CloseProcess, OFF
Hotkey, %exitEmulatorJoy%, CloseProcess, OFF
Run, %emupath%%executable%
sleep, 1000
Process, Close, PCLauncher.exe
Runwait, %rompath%%romname%%romextension%
WinGet, NewPID, PID, A
Process, priority, %NewPID%, High
;MsgBox The newly launched PCGame's PID is %NewPID%.
WinActivate, %NewPID%
Process, waitClose, %executable%
Process, Close, %NewPID%
WinActivate, HyperSpin
}
Overall, functionality is the same, the code is reduced a bit (every CPU cycle helps, right?), and it gives me my extra %exitEmulatorJoy% that I wanted. Win all around! Thanks for the help, Blur!
great job
as you probably saw :: commands are not good cause they will be active always regardless of where you put :: code - they don't follow if structures.
and when you use them with #ifwinactive to make them active only when some window is active - they stop ahk execution on that line :)