【问题标题】:How do I send a key multiple times in Autohotkey?如何在 Autohotkey 中多次发送密钥?
【发布时间】:2018-01-24 18:59:59
【问题描述】:

我想编写一个按 X 次键的 AutoHotkey 脚本。例如,这是一个按 Tab 10 次的脚本。

Send, {Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}

虽然上述解决方案有效,但有点笨拙。

是否有更好的解决方案来多次发送密钥?

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    尝试使用Send {Tab 10}

    Repeating or Holding Down a Key

    重复击键:用大括号括起来后面的键名 通过重复它的次数。例如:

    Send {DEL 4}   ; Presses the Delete key 4 times.
    Send {S 30}    ; Sends 30 uppercase S characters.
    Send +{TAB 4}  ; Presses Shift-Tab 4 times.
    

    来源AutoHotkey - Send / SendRaw / SendInput / SendPlay / SendEvent: Send Keys & Clicks


    这也适用于ControlSendControlSendRaw

    ControlSend, Edit1, {Enter 5}, Untitled - Notepad
    

    【讨论】:

    • 如何参数化字符和数字?因此,如果我在记事本上按“Ctrl + op + $ + 8”,它应该在同一行中总共打印 8 次“$”。并且“Ctrl + op + # + 5”应该在同一行打印字符“#”总共5次
    • 如何多次发送多个密钥,例如^+,
    • @JinSnow 你可以使用循环,比如Avatar’s answer
    • 谢谢!这有效:loop 4send ^+,
    【解决方案2】:

    如果您希望循环重复,假设每 3 秒一次:

    #a::   ; Win+a
    Loop, 10
    {
        SendInput {Tab}
        Sleep, 3000
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-06
      • 2021-01-01
      • 1970-01-01
      • 2015-09-06
      相关资源
      最近更新 更多