如何在 Autohotkey 中重新映射 CTRL-x CTRL-c? [英] How can I remap CTRL-x CTRL-c in Autohotkey?

查看:39
本文介绍了如何在 Autohotkey 中重新映射 CTRL-x CTRL-c?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近搬到了 Emacs(并成为了粉丝),我想使用 Autohotkey 来制作 Ctrl+X Ctrl+C 一个通用的关闭"命令.

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.

这是我的 .ahk 文件中的内容:

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:

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

无论是按下还是释放 C 键(我不介意哪个),活动窗口都会关闭.

On either pressing or releasing the C key (I don't mind which), the active window is closed.

成功案例:我已经通过 Honest Abe 实现了答案,添加了一个小调整以避免实际操作时的烦恼使用 Emacs 本身.这是最终结果(谢谢,HA!):

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

推荐答案

这里有一个例子,它在 Control + 之后等待 0.6 秒 C 被按下X:

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

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

如果 C 在 0.6 秒内没有被按下 Control + X 被发送.
$ 用于在热键发送自身时的最开始(以避免无限循环).

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

手册参考:
$
keywait

这篇关于如何在 Autohotkey 中重新映射 CTRL-x CTRL-c?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆