【问题标题】:Send RButton after holding LButton for time按住 LButton 一段时间后发送 RButton
【发布时间】:2018-02-01 16:32:23
【问题描述】:

我正在尝试制作一个脚本,在按住 LButton 特定时间后按下 RButton 并忽略左键单击。我不知道该怎么做。

伪代码:

timer = 0;

while(LButton down){
add 1 to timer?

if(timer==100){
Send {RButton}
ignore LButton
reset timer
}
}

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    使用 A_TickCount 作为衡量时间流逝的一种快速简便的方法。

    (已测试)

    LButton::
    StartTime := A_Tickcount
    WaitTimeInMilliSeconds = 1000
    tooltip trying
    while(StartTime+WaitTimeInMilliSeconds > A_Tickcount)
    {
         if(!GetKeyState("LButton","P"))
         {
             click ;send the click anyway if it's not held.
             return
         }
    }
    tooltip this happens after 1000 milli second of continuously holding left mouse button
    return
    

    如果你把它放在鼠标左键热键中,它会自动重置。如果你想让它一直循环,你可以把整个东西放在一个无限循环中并重置开始时间而不是return

    【讨论】:

    • 不知道我怎么用错了,但我似乎不明白如何让它工作。
    • 我更改了代码,现在应该可以正常工作了,只需将工具提示替换为您需要的任何内容即可。在将其复制到堆栈溢出之前,我必须撤消太多更改。
    • 感谢您的帮助,脚本可以正常工作,但现在我根本无法左键单击。我想我需要检查它的时间是否少于 WaitTimeInMilliSeconds 并发送 {LButton}?
    • 只需在 LButton:: 前面放一个 ~ 。这使得点击“通过”,所以它正常点击并触发热键。
    • 嗯,如果我按住 LButton,我希望它忽略左键单击,那么有没有办法可以使用 LButton Down 启动计时器,并且只在 LButton Up 之后注册左键单击,如果计时器小于 WaitTimeInMilliSeconds?
    猜你喜欢
    • 1970-01-01
    • 2021-01-10
    • 1970-01-01
    • 2020-03-03
    • 2016-12-01
    • 1970-01-01
    • 2019-01-17
    • 2014-01-09
    • 1970-01-01
    相关资源
    最近更新 更多