【问题标题】:How to use two keys as trigger AutoHotKey?如何使用两个键作为触发 AutoHotKey?
【发布时间】:2021-06-19 02:26:33
【问题描述】:

我想使用ctrl + w + x 作为热键,但^wx:: 当然是无效的热键。

这里是我找到的资源,我试过了,但它们对我不起作用,(虽然英语不是我的母语,所以我可能误读了??)

键列表的 AutoHotKey 文档 https://www.autohotkey.com/docs/KeyList.htm

名为“同时按下 2 个按钮?”的 AutoHotKey 主题从 2018 年开始 https://www.autohotkey.com/boards/viewtopic.php?t=45869

2014 年的另一个名为“尝试使用 2 个键激活按键”的 Autohotkey 主题 https://autohotkey.com/board/topic/109093-trying-to-activate-a-key-press-using-2-keys-tried-a-bc-error-on-run-help-please-s/

提前感谢您帮助我:)

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    这是基于first example from the Input command in the Documentation 的一种解决方案:

    delay := 3.0 ;number of seconds to wait for additional input
    
    $^w::
    Input, SingleKey, L1T%delay%, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{CapsLock}{NumLock}{PrintScreen}{Pause}
    if (SingleKey = "x"){
        ;;;;;;;
        MsgBox Put Hotkey here
        Send ctrl + w + x was pressed
        ;;;;;;;
    }
    else{
        Send {Ctrl Down}{w}{Ctrl Up}
        Send %SingleKey%
    }
    
    return
    

    代码说明:

    设置:

    声明一个变量来保存您希望热键在按下 Ctrl+w 后等待“x”输入的时间,称为 delay

    热键声明:当 Ctrl+w 被按下时

    1. 等待delay 用户按下另一个键的秒数
    2. 如果该键是 x,则发送您的自定义热键
    3. 否则,发送 Ctrl+w,后跟用户按下的任何键。

    其他说明:

    1. 使用$ 热键修饰符防止无限递归循环

    如果它不能正常工作,请随时告诉我,我会尽力帮助你

    【讨论】:

    • 有趣的是,如果 ctrl 和 w 键按下,当我按下 X 时不会触发 if 语句,必须完全单独按下 x
    猜你喜欢
    • 2016-02-28
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    • 2018-03-18
    • 1970-01-01
    • 1970-01-01
    • 2013-06-22
    • 1970-01-01
    相关资源
    最近更新 更多