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

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

问题描述

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

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.

这是我的.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.

成功案例:我已经通过诚实的安倍实现了答案,并做了一些细微的调整,以避免在实际使用时产生烦恼使用Emacs本身.这是最终结果(谢谢,谢谢!):

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

如果在0.6秒内未按 C ,则发送 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).

手册参考:
$
密钥等待

Manual references:
$
keywait

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

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