简体   繁体   English

如何在 Autohotkey 中重新映射 CTRL-x CTRL-c?

[英]How can I remap CTRL-x CTRL-c in Autohotkey?

Having recently moved to Emacs (and become a fanboy), I'd like to use Autohotkey to make Ctrl + X Ctrl + C a universal "Close" command.最近搬到 Emacs(并成为粉丝),我想使用 Autohotkey 使Ctrl + X Ctrl + C成为通用的“关闭”命令。

Here's what I have in my .ahk file:这是我的.ahk文件中的内容:

; 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:为了澄清我的击键,这里是序列:

  1. Hold down the CTRL key按住CTRL
  2. Press and release the X key按下并松开X
  3. Press and release the C key按下并松开C
  4. Release the Ctrl key松开Ctrl

On either pressing or releasing the C key (I don't mind which), the active window is closed.在按下或释放C键(我不介意哪个)时,活动窗口将关闭。


Success story: I have implemented the answer by Honest Abe , adding a small tweak to avoid annoyance when actually using Emacs itself.成功案例:我已经实现了Honest Abe的答案,添加了一个小调整以避免在实际使用 Emacs 时产生烦恼。 Here's the end result (thanks, HA!):这是最终结果(谢谢,哈!):

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

Here is an example that waits 0.6 seconds for C to be pressed after Control + X :这是一个在Control + X之后等待 0.6 秒C被按下的示例:

$^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.如果在 0.6 秒内没有按下C,则发送Control + X。
$ is used at the very beginning when a hotkey sends itself (to avoid an infinite loop). $在热键发送自身时最开始使用(以避免无限循环)。

Manual references:手册参考:
$ $
keywait键等待

While this isn't a direct answer to your question, you may want to look at XKeymacs if you haven't already, http://www.cam.hi-ho.ne.jp/oishi/indexen.html虽然这不是您问题的直接答案,但如果您还没有,您可能想查看 XKeymacs, http://www.cam.hi-ho.ne.jp/oishi/indexen.html

It gives you ALOT of Emacs functionality within all/most windows apps.它在所有/大多数 Windows 应用程序中为您提供了很多 Emacs 功能。 As with Emacs it is highly configurable, so you can enable/disable Emacs bindings on a global or application level.与 Emacs 一样,它是高度可配置的,因此您可以在全局或应用程序级别启用/禁用 Emacs 绑定。

It may not be the right solution for everyone, but I can't live without it.它可能不是每个人的正确解决方案,但我不能没有它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM