<p>I'm trying to set up <a href="http://www.autohotkey.com/" rel="nofollow noreferrer">AutoHotkey</a> macros for some common tasks, and I want the hotkeys to mimic Visual Studio's "two-step shortcut" behaviour - i.e. pressing <kbd>Ctrl</kbd>-<kbd>K</kbd> will enable "macro mode"; within macro mode, pressing certain keys will run a macro and then disable 'macro mode', and any other key will just disable macro mode.</p>

<p>Example - when typing a filename, I want to be able to insert today's date by tapping <kbd>Ctrl</kbd>-<kbd>K</kbd>, then pressing <kbd>D</kbd>.</p>

<p>Does anyone have a good example of a stateful AutoHotkey script that behaves like this?</p>

This Autohotkey script, when you press
ctrl
+
k
, will wait for you to press a key and if you press
d
, it will input the current date.
```
```
^k::
Input Key, L1
FormatTime, Time, , yyyy-MM-dd
if Key = d
    Send %Time%
return
```
```