Main > Software Forum
AHK fun!
SpamMe:
I've been having a lot of fun with autohotkey also (though, admittedly, I'm not great with it).
Script below causes the escape key to work only if it's held for 2 seconds or more (or you can hit it rapidly to toggle this function back off) to prevent accidental exiting in mame and so forth.
--- Code: ---;HoldEscape:
toggletimer = 0
esckill = 1
SetKeyDelay, 10, 20
$esc::
if toggletimer = 0
SetTimer, resettimer, 1000
toggletimer++
if toggletimer > 3
goto, toggleesckill
if esckill = 1
{
tt=0 ; set time to 0
loop,100
{
GetKeyState, s , esc, p
if s=U
Break
tt+=25
sleep 25
}
if tt>=2000 ; if key pressed for 2 or more sec
{
send, {esc}
toggletimer = 0
sleep 1200
}
}
else
{
send, {esc}
}
return
resettimer:
toggletimer = 0
return
toggleesckill:
soundplay, *48
toggletimer = 0
esckill *= -1
sleep 500
return
--- End code ---
I also wrote one to act as a coin counter (pops up a translucent panel over mamewah showing a total dollar amount taken at bootup or when coming back up from standby for a few seconds and then fades out), but, as I used Veinman's lil coin counter as a gui template for it (and because it waits for mamewah, specifically, to start), I don't think I can release it.
Oh. Here's a wrapper for EveryExtend (remaps keys and dismisses the first opening dialog).
--- Code: ---;change this line to suit your folder paths
Run, C:\EveryExtend\SGX2.exe, C:\EveryExtend,
SetTitleMatchMode, 3
WinWait, Project-SGX2, Fullscreen mode?,5
if ErrorLevel = 1
goto, Kill
ControlSend,, y, Project-SGX2, Fullscreen mode?
WinWait, Project-SGX2,,8,Fullscreen mode?
if ErrorLevel = 1
goto, Kill
SetTimer, close, 1000
*q::
*w::
*e::
*r::
*t::
*y::
*Enter::
Send {z down}
Return
*q up::
*w up::
*e up::
*r up::
*t up::
*y up::
*Enter up::
Send {z up}
Return
Close:
IfWinNotExist, Project-SGX2
exitapp
Return
kill:
winkill, Project-SGX2
exitapp
Return
--- End code ---
MisterB:
This one isn't pretty, but I use it as a wrapper for the Sega Saturn emulator Cassini. I couldn't find a way to launch it cleanly from the command line - it wants to launch a GUI where you can tweak a bunch of settings before running the game in your (real or virtual) CD-ROM drive. The wrapper automatically navigates through the GUI, forcing the system BIOS to US (default is always Japan), then starts the game. On XP systems, a DirectSound error always pops up when the game starts. This script also bypasses that error message (btw - sounds seems to work fine regardless of the error).
By default, Cassini exits the game when you press ESC, but brings you back to the GUI again. The script also detects the game exit, and closes the GUI for you.
No problems running this script using MameWah, if you compile it into an .exe. I configured MameWah to auto-mount my CD image before running the AHK script, but the script could be modified to do that as well...
Run, "G:\emulators\cassini\Sega_Saturn_Emulator.exe"
WinWait, Cassini
WinActivate
Send, {tab}{tab}{tab}{tab}{tab}{down}{down}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{enter}
WinWait, Error
WinActivate
Send, {enter}
WinWait, Cassini
WinActivate
WinClose
SpamMe:
I was using mamewah as a shell, but needed to run a few other apps at startup (without making them services).
Here's the shell I'm using now:
--- Code: ---/*
AHK Shell
This script is basically a batch file
for launching programs based on entries
in an ini file (named AHKShell.ini) placed
in the same folder as the script. It will
need to be compiled with AHK2EXE
for use as a shell.
*/
SetWorkingDir, %A_ScriptDir%
IniRead, AppNum, AHKShell.ini, Settings, NumberOfApps, 0
Loop, %AppNum%
{
IniRead, App%A_Index%, AHKShell.ini, Applications, App%A_Index%
}
Loop, %AppNum%
{
CurrentCommandLine := App%A_Index%
StringSplit, NameArray, CurrentCommandLine, `,,%A_Space%
SplitPath, NameArray1,,ApplicationDirectory
Run, "%NameArray1%" %NameArray2%, %ApplicationDirectory%, UseErrorLevel
}
--- End code ---
And ini file
--- Code: ---[Settings]
NumberOfApps=2
[Applications]
App1=C:\Program Files\VolumeTray\Volumetray.exe
App2=C:\program\someprogram.exe, -someparameter
App3
App4
App5
App6
App7
App8
App9
App10
--- End code ---
Howard_Casto:
since we are sharing.....
I enjoy the american laser games, but they aren't exactly cab friendly.. this is the script I use with them:
--------------------------------------------------------------------------------
; The asterisk prefix makes the remapping more complete on XP/2k/NT. For 9x systems you can remove it.
IfWinNotExist,The Last Bounty Hunter
{
winwait,The Last Bounty Hunter,,100
WinActivate,The Last Bounty Hunter
Send {LAlt down}
Send {C down}
Send {LAlt up}
Send {C up}
Send {F up}
Send {F down}
return
}
else
{
WinActivate,The Last Bounty Hunter
Send {LAlt down}
Send {C down}
Send {LAlt up}
Send {C up}
Send {F up}
Send {F down}
return
}
*1::Send {LControl down}
*1 up::Send {LControl up}
Escape::
Send {LAlt down}
Send {F4 down}
Send {LAlt up}
Send {F4 up}
ExitApp ; Assign a hotkey to terminate this script.
return
----------------------------------
Bascally what this does is check to see if the game is running... if it is, go through the menus to set it to fullscreen. If not, wait for the game and then set fullscreen mode.
It also translates escape, to press alt-f4, which closes any standard windows app, not just the alg games.
On top of that I translated the 1 key to left control, so when the "press start" screen appears, I can start the game by actually pressing start, instead of firing at the screen or pressing any "standard" key.
This script will work with just about any digital leisure game, you just have to change the caption in the script to reflect the caption of that app's window. Also note that if your folder name matches the caption name of the window, it will screw things up when testing through explorer... so use the command line only.
Tiger-Heli:
Cool stuff, and I didn't realize AHK grew out of AutoIt. Have actually used both programs!!!
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version