【问题标题】:Sending a key while other key is pressed doesn't spam the pressed key在按下其他键的同时发送一个键不会向按下的键发送垃圾邮件
【发布时间】:2020-04-15 15:03:15
【问题描述】:

我正在尝试编写一个脚本以在按下另一个按钮时发送一个按钮,例如

$c::
    send {c down}
    sendQ()
    send {c up}
return
sendQ()
{
    if GetKeyState("c","P") {
        sendinput {q}
        sleep 2222
    }
}

它可以工作,但不如预期。 它以 2222 间隔发送 cq,如 cq..cq..cq 我需要这样的结果:cqcccccccqccccccccqcccc 有没有办法在按间隔按“q”时发送垃圾邮件“c”?

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    这似乎有效:

    isCPressed := 0
    
    c::
        Send c
        if (!isCPressed) { ; Avoid resetting the timer
            SetTimer, SendQ, 2222
        }
        isCPressed := 1
    Return
    
    c Up::
        SetTimer, SendQ, Delete
        isCPressed := 0
    Return
    
    SendQ() {
        SendInput q
    }
    

    在大多数情况下,你也可以替换

    c::
        Send c
    

    ~c::
    

    【讨论】:

      【解决方案2】:

      在 ahk 中伪造多线程可以产生所需的输出。这样,脚本可以在等待指定的时间后,在各自的线程中同时发送 c 和 q。

      #Persistent
      
      ~c::
          Send, q ;~ for initial cq
          SetTimer, sendC, 100 ;~ frequency of sending c
          SetTimer, sendQ, 2222 ;~ frequency of sending q
      return
      
      ;~ Sending c
      sendC:
          Send, c
      return
      
      ;~ Sending q
      sendQ:
          Send, q
      return
      

      【讨论】:

      • ty 回复,它不是完全在按键上,但感谢你的想法。它向 c 发送垃圾邮件并在 c 按下时发送 q
      猜你喜欢
      • 2011-08-12
      • 2014-03-07
      • 1970-01-01
      • 2020-10-12
      • 2020-10-07
      • 1970-01-01
      • 2014-11-02
      • 2012-07-01
      • 2016-10-25
      相关资源
      最近更新 更多