How to reassign CTRL-x CTRL-c to Autohotkey?

I recently moved to Emacs (and became a fan), I would like to use Autohotkey to make Ctrl + X Ctrk + C the universal Close command.

Here is what I have in the .ahk file:

 ; Universal Close :*:^x^c:: WinClose, A Return 

which does not seem to work. What am I doing wrong?


To clarify my keystrokes, here is the sequence:

  • Hold the Ctrl key;
  • Press and release the X key;
  • Press and release the C key;
  • Release the Ctrl key.

When you press or release the C key (I do not mind), the active window closes.


Success Story: I followed Honest Abe 's answer by adding a little tweak to avoid annoyance when Emacs is actually used. Here's the end result (thanks, GA!):

 ; Universal Close $^x:: IfWinActive, ahk_class Emacs Sendinput, ^x Else { keywait, c, d, t0.6 If ErrorLevel Sendinput, ^x Else WinClose, A } Return 
+4
source share
2 answers

Here is an example that waits for C to be pressed for 0.6 seconds after Control + X :

 $^x:: keywait, c, d, t0.6 If ErrorLevel Sendinput, ^x Else WinClose, A Return 

If C is not pressed within 0.6 seconds, Control + X is sent.
$ used at the very beginning when the hotkey sends itself (to avoid an infinite loop).

Reference Guides:
$
keywait

+4
source

Although this is not a direct answer to your question, you may want to take a look at XKeymacs if you have not already done so, http://www.cam.hi-ho.ne.jp/oishi/indexen.html

It gives you the ability to use Emacs in all / most Windows applications. Like Emacs, it is very customizable, so you can enable / disable Emacs bindings at the global or application level.

This may not be the right decision for everyone, but I cannot live without it.

+1
source

All Articles