AHK 2 — Header for DAoC
What?
#Requires AutoHotkey v2.0
#UseHook
#SingleInstance Force
#HotIf WinActive("ahk_class DAoCMWC")
#MaxThreadsPerHotkey 5
SendMode "Event"
A_MaxHotkeysPerInterval := 200
Why?
This snippets should be present at the very top of each of your scripts. It sets global values and settings for the entire script
How?
-
# Requires AutoHotkey v2.0
ensures that your computer knows to start this script with the right version of AHK. -
# UseHook
requires the script to be triggered only by the actual keyboard.- This mainly means a macro cannot trigger itself or another macro by mistake.
- The typical example is to want the hotkey
1
to not only send the keystroke1
to the game, but alsoF
to face your target first. Without# UseHook
, to prevent this from turning into a recursive loop, you'd have to add$
in front of the hotkey.
# SingleInstance Force
forces a currently running version of this script to be replaced by the new one without confirmation when you try to run the script again. This is really helpful when editing and trying new things constantly.
-
# HotIf WinActive("ahk_class DAoCMWC")
tells the script to be only active while you focus the Dark Age of Camelot window. -
# MaxThreadsPerHotkey 5
ensures that if you repeatedly press a single key, these presses are actually recorded and queued, rather than lost if the related macro takes too long to process. If you wish to avoid accidental double-presses instead, remove this line. -
SendMode "Event"
switches the default mode for theSend
command to beSendEvent
. I'm not sure I completely understand the difference between this andSendInput
(the default setting), but adding this removed some bugs from my scripts. -
A_MaxHotkeysPerInterval := 200
sets the delay between each keystroke sent by AHK to the game. The default (70 ms) seems to be too small for DAoC, which then misses some values. 200 ms just... worked for me. Feel free to try other values.