Having recently moved to Emacs (and become a fanboy), I'd like to use Autohotkey to make Ctrl+X Ctrk+C a universal "Close" command.
Here's what I have in my .ahk
file:
; Universal Close
:*:^x^c::
WinClose, A
Return
which doesn't appear to work. What am I doing wrong?
To clarify my keystrokes, here is the sequence:
- Hold down the CTRL key;
- Press and release the X key;
- Press and release the C key;
- Release the Ctrl key.
On either pressing or releasing the C key (I don't mind which), the active window is closed.
Success story: I have implemented the answer by Honest Abe, adding a small tweak to avoid annoyance when actually using Emacs itself. Here's the end result (thanks, H.A.!):
; Universal Close
$^x::
IfWinActive, ahk_class Emacs
Sendinput, ^x
Else {
keywait, c, d, t0.6
If ErrorLevel
Sendinput, ^x
Else
WinClose, A
}
Return