PDA

View Full Version : autohotkay escape/pause



caskad
08-31-2011, 02:56 AM
Hello,

After trying to manage esc butons in HL2.0, i failed lol :D

So i try to add in each module this kind of script because my x-arcade have lost 4 buttons...



i need to know 2 things:

i recompile hyperlaunch wit exitemulatorkey = ~esc

in Mame, fine esc dosen't work so i try this kind of code eg For Mame (but it works fine to exit other emulator)


;----------------------------------------------------------------------------
; MAME
; MAME .140
; by BBB
; 1.0
;
; Info:
; Since MAME needs to save hi scores and data on exit, then we can't force
; MAME closed with a hotkey. So make sure you have your own exit key setup
; in MAME first. We will leave the CloseProcess section below blank, but
; it is still required.
;
;----------------------------------------------------------------------------

Runwait, %executable% %romName%, %emuPath%, Hide UseErrorLevel

if(ErrorLevel != 0){
if (ErrorLevel = 1){
Error = Failed Validity
}else if(ErrorLevel = 2){
Error = Missing Files
}else if(ErrorLevel = 3){
Error = Fatal Error
}else if(ErrorLevel = 4){
Error = Device Error
}else if(ErrorLevel = 5){
Error = Game Does Not Exist
}else if(ErrorLevel = 6){
Error = Invalid Config
}else if(ErrorLevel = 7 || ErrorLevel = 8 || ErrorLevel = 9){
Error = Identification Error
}else{
Error = Mame Error
}
MsgBox Mame Error - %Error%
}

ExitApp


CloseProcess:
KeyWait, Esc, T1
if ErrorLevel
{
Hotkey, %exitEmulatorKey%, Off
send, {p}
Hotkey, %exitEmulatorKey%, On

return
}
else
{
Hotkey, %exitEmulatorKey%, Off
send, {Esc}
Hotkey, %exitEmulatorKey%, On
return
}

i works while olding "esc" button during 2 seconds, but i figure out, can i assign the "p" buton if i push it rapidly? (for pause or select 1/2 eg:for supernes)

because, i've lost 4 buttons on my X-arcade,other solution:

Can i assign esc with combo key like "d" & "i" (start/left) with autohotkey??

i try various script like

#ifWinActive ahk_class Mame
~d & ~i:: send !{f4}


#ifWinActive ahk_class Zsnes
~d & ~i:: send !{f4}


it works fine but i cannot assign this to esc if i try:


#ifWinActive ahk_class Mame
~d & ~i:: send {esc}


so for me 2 solutions:

using esc with safe and one button
using combo for esc (prefered!)

Hope this is cleard, i'm french :)

thx !

BadBoyBill
08-31-2011, 06:03 PM
You set your escape keys in settings.ini, not in the HyperLaunch file, you should never need to touch HyperLaunch or recompile or anything, that was the whole point of HL2.0

caskad
09-01-2011, 03:41 PM
Thx bbb,


but it doesn't work, i try step one of hl2.0 topics, but it' failed :s

i put autohotkey.dll hyperlaunch.exe in hs folder, and add in system ini, the line requierd.

i try "d" & "i" and ~d &~i, but nothing ?

"exit_emulator_key= meens defaut emualtor or something else? i need to have 2 butons to simulate escape and gain the attibut to save highscore :)


[Main]
Menu_Mode=multi
Single_Mode_Name=MAME
Enable_Exit_Menu=true
Enable_Exit=true
Exit_Default=yes
Exit_Action=exit
Version=1.0.0.0

[HyperLaunch]
exit_script_key=~q & ~s
exit_emulator_key=~d & ~i
toggle_cursor_key=~t
hide_cursor=false
hide_desktop=false
hide_taskbar=false
path_to_daemontools=
path_to_cpwizard=
cpwizard_delay = 8000
cpwizard_params = -timeout 9000
last_system=MAME
last_rom=1942

blur
09-02-2011, 01:58 AM
you won't save high scores with exit emulator key

exit emulator key usually kills process

if you want to save high score you have to define exit key in your game, and undefine exit key in ahk

at least that was the situation in hyperlaunch 1.0, not sure about 2.0

but looking at code in your post - looks like it is the same:

; Info:
; Since MAME needs to save hi scores and data on exit, then we can't force
; MAME closed with a hotkey. So make sure you have your own exit key setup
; in MAME first. We will leave the CloseProcess section below blank, but
; it is still required.


you can however send different exit key depending on application without ahk killing the game.

that should not be a problem

forget about hyperlaunch - think what you want to do and do it outside of hyperlaunch in some small ahk test script

when this script does what you want you can try to put it in hyperlaunch

i'm saying this cause i think you have some major syntax errors
for example every
#ifwinactive mame ... - needs closing statement

#ifwinactive

and so on

Hypnoziz
09-02-2011, 10:56 AM
Just open MAME and assign the exit key to Escape or whatever key combo you want. In MAME, it's called "UI CANCEL".

blur
09-02-2011, 01:16 PM
here is the reason why using :: doesn't work for you



Creating hotkeys via double-colon labels performs better than using the Hotkey command because the hotkeys can all be enabled as a batch when the script starts (rather than one by one). Therefore, it is best to use this command to create only those hotkeys whose key names are not known until after the script has started running. One such case is when a script's hotkeys for various actions are configurable via an INI file.


which means :: is executed on start of the script, before any other command, and before any variable is assigned
so if your key is in some variable or in some ini file (and it is) - you can't use ::

:: can be used only for keys hardcoded in script (key before and after :: has to be hardcoded or :: will not work)

caskad
09-02-2011, 11:06 PM
Thx Blur and hypnozis :)

i test a small AHK script outside of Hyperspin, and it doesn't worf :s

After all, i've add in each module this :


CloseProcess:
KeyWait, Esc, T1

Hotkey, %exitEmulatorKey%, Off
send, {Esc}
Hotkey, %exitEmulatorKey%, On
return
}

because my start button and esc button are closed, if i push esc ... i will not exit :)

works fine with some emu like mame or mednafen, zsnes ... not on nestopia but it's fine.

:burnout:

blur
09-03-2011, 05:47 PM
are you saying that your esc key is pressed all the time because of some error in your xarcade?

caskad
09-04-2011, 10:45 PM
No,

after trying to connect a coin door (MArs ME110), i've lost j6 connector on my x-arcade.

4 buttons are missing :s

so escape key was remap to another button close to stat button (under the 6 firts on the left :))

i need to keywait this because sometime, i push it.

but it' s fine, after all, i sold my cab for another with J-pac inside :)

Edit:

Simple question , i test an alternative method while pushing this keywait with error level1

exemple push it: = F2
holding down = Esc

no succes


KeyWait, Esc, T1
if ErrorLevel
{
Hotkey, %exitEmulatorKey%, Off
send, {F4}
Hotkey, %exitEmulatorKey%, On

return
}
else
{
Hotkey, %exitEmulatorKey%, Off
send, {Esc}
Hotkey, %exitEmulatorKey%, On
return
}

what's wrong?

blur
09-05-2011, 01:03 AM
oh so you have problems only with key press detection?

Test your script with keyboard first.

Some controllers have different way of sending keys so in some cases ahk can't detect if key is pressed or not.

If your script works with keyboard but not with xarcade then you can't detect keypress and can't use long press/short press features.

About this script - if that is your whole testing script - it has some parts missing.

you can't just put code from closeprocess subroutine and expect it to work, script has to have head and tail.

try with this script:



; Key press testing utility
; Author: blur
; Purpose:
; This little script tests if ahk is capable of detecting if your Esc key is pressed or not.
; First test it with your keyboard, then with your controller

; first you set hot key
Hotkey, Esc, CloseProcess


; now you need return so that script won't go to your subroutines part
return

; and now subroutines

CloseProcess:
KeyWait, Esc, T1
if ErrorLevel
{
MsgBox You are holding Esc key
return
}
else
{
MsgBox You are not holding Esc key
return
}
return ; end of CloseProcess subroutine