Tiger-Heli
Full Member
  
Online
Posts: 4075

Ron Howard? . . . er, I mean . . . Run, Coward!!!
|
FYI, you can assign a block of code to multiple keys by listing them like labels:
~Z::
~X::
~LShift::
{
do something here
}
return
Cool - I was looking for a way to do this. BTW, my code works, so
I think (this will ramble), but say you wanted Johnny5 to launch before
MAME and then exit with any key and launch MAME and then come up when
you paused MAME and then exit when you pressed any key.
The second part consists of a file - C:\mamebat\default.bat
echo off
c:
cd\
cd johnny
start johnny5.ahk %1
cd\
cd mame
mame %1
exit
and a johnny5.ahk script:
#SingleInstance force
#Persistent
; The asterisk prefix makes the remapping more complete on XP/2k/NT. For 9x systems you can remove it.
DetectHiddenWindows, On
ScreenState =0
~P::
{
if ScreenState > -1
{papaschtroumpf
If ScreenState =1
{
ScreenState=-1
BlockInput On
send, {Escape down}
send, {Escape up}
WinActivate,%Title%
WinRestore,%Title%
WinActivate,%Title%
WinWaitActive,%Title%
sleep 250
Send,{p down}{p up}
ScreenState=0
BlockInput Off
}
else
{
BlockInput On
ScreenState=-1
WinGetActiveTitle, Title
sleep 100
J5=Johnny5.exe %1% -ahk 1000
if 0 >1
J5=%J5% -clone %2%
if 0 >2
J5=%J5% -driver %3%
Run,%J5%, C:\johnny\, max
ScreenState=1
BlockInput Off
}
}
}
return
~Up::
~Down::
~Left::
~Right::
~Control::
~Alt::
~Space::
[color=Red]All your other CP keys[/color]
If ScreenState =1
{
ScreenState=-1
BlockInput On
WinActivate,%Title%
WinRestore,%Title%papaschtroumpf
WinActivate,%Title%
WinWaitActive,%Title%
sleep 250
Send,{p down}{p up}
ScreenState=0
BlockInput Off
}
return
~Escape::
if ScreenState=1
{
BlockInput On
ScreenState=-1
send, {Escape down}papaschtroumpf
send, {Escape up}
WinActivate,%Title%
WinRestore,%Title%
WinActivate,%Title%
WinWaitActive,%Title%
sleep 250
Send,{p down}{p up}
ScreenState=0
BlockInput Off
}
else
{
ExitApp
}
return
This launches the AHK Script and Johnny5 launches when MAME is paused and exits back to MAME when any CP key is pressed.
Now you write a start.ahk Script as follows (in the c:\Johnny directory):
#SingleInstance force
#Persistent
; The asterisk prefix makes the remapping more complete on XP/2k/NT. For 9x systems you can remove it.
DetectHiddenWindows, On
ScreenState =0
~Up::
~Down::
~Left::
~Right::
~Control::
~Alt::
~Space::
[color=Red]All your other CP keys[/color]
{
send, {Escape down}
send, {Escape up}papaschtroumpf
M1=default.bat %1%
Run,%M1%, C:\mamebat
ExitApp
}
return
This simply exits Johnny5 when any CP key is pressed and launches the batch file above which launches MAME. . .
Then you write a batch file named C:\mamebat\start.bat - as follows:
echo off
c:
cd\
cd johnny
johnny5 %1
start start.ahk %1
exit
This simply launches Johnny5 and launches the start script which will close Johnny5 and launch MAME.
I haven't tested it, but it sounds like it might work.
|