AHK 2 — Various Suspends
Toggle suspend on specific key
What?
#SuspendExempt
+q::
{
Suspend(-1)
ToolTip(A_IsSuspended ? "Script Suspended" : "")
}
Why?
This allows your script to be suspended or turned back on when you press a specific key (Here, Shift + q
as an example.)
Toggle suspend on Enter
What?
#SuspendExempt
~NumpadEnter::
~+Enter::
~Enter::
{
Suspend(-1)
ToolTip(A_IsSuspended ? "Script Suspended" : "")
}
Why?
This allows your script to automatically pause when you're pressing Enter to type in chat, and resume when you press it again to send your message.
Resume script on Escape
What?
#SuspendExempt
~esc::
{
Suspend(false)
ToolTip()
}
Why?
This ensures that pressing Escape resumes your script, always. It often happens that you'll naturally exit a situation where the script needs to be suspended (typing...) by pressing the Escape key.
Suspend script on other keys that open chat
What?
~+r::
{
Suspend(true)
ToolTip(A_IsSuspended ? "Script Suspended" : "")
}
Why?
This will make sure your script suspends (and only suspend, not resume) when hitting one of the keys that can trigger the in-game chat. In the example above, Shift+r
, which I use to answer to whispers.
Note that just like the Suspend on Enter script, you can add more keys to this without having to copy paste the whole block multiple times.
How are these working?
-
# SuspendExempt
right before a macro makes it so the following hotkeys will trigger even when the script is suspended. This is necessary for all the hotkeys that resume your script, or they will never trigger! -
~
is used often in front of these hotkeys. The~
symbol tells AHK that instead of intercepting the key and preventing DAoC from receiving it, it'll let it pass through. This way, DAoC will indeed open chat, or answer to a whisper, etc. -
Tooltip("message")
prints the message written between the parenthesis in a small window next to where your mouse cursor is.Tooltip()
orTooltip("")
clears the tooltip.A_IsSuspended ? "Script Suspended" : ""
is AHK's Ternary Operator. You can read it as If this script is suspended, write "Script Suspended". If not, write "". It's single line if-then-else statement.