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?