【问题标题】:Delay RButton after LButton在 LButton 之后延迟 RButton
【发布时间】:2013-03-06 19:39:21
【问题描述】:

我运行的应用程序在 LButton 之后过早删除了 RButton。解决方案可能是运行类似

~LButton::                    ; pass through, set A_PriorHotkey
return

#If A_PriorHotkey = LButton && A_TimeSincePriorHotkey < minDelay
RButton:: 

但是我在写最后一行和以下行时没有运气,因此如果#IF 为假或延迟大约 100 毫秒,则发送正常的 MButton down 和 RButton up 如果 #如果是真的。

提前致谢。

【问题讨论】:

  • 首先您需要知道是否可以“捕获”来自应用程序的 RButton。试试:RButton::SoundBeep, 500,500 看看 AutoHotKey 是否可以通过这种方式触发,或者您可能需要使用 VK/SC 代码。
  • RButton::SoundBeep,500,500 在应用程序中工作。对于答案 1
  • @罗伯特:谢谢。不是所有的右击都应该延迟,只有左击之后的那些。
  • @Armin:谢谢。您的代码在定时期间会杀死所有右键单击。我需要在定时期限后右键单击,而不是消失。我想我可以调整你的方法来做到这一点。
  • 好的,所以您只想延迟左键单击之后的右键单击。所有其他右键单击都应无延迟传递!

标签: autohotkey


【解决方案1】:

这是一个应该可以工作的解决方案,我对其进行了一些测试,它应该 100% 的时间都可以工作。 如果您使用它,请不要只是复制和粘贴,而是要尝试了解代码的作用。

基本上我们所做的是在左键单击时我们计时直到达到某个时间(在本例中为 1000 毫秒 -> IGNORE_TIME),同时我们忽略右键单击,当时间到时右键单击再次处于活动状态。

global IGNORE_TIME := 1000  ; ignore for 1000 miliseconds, change only this if you wan't different times
global starttime := 0


~LButton::
    SetTimer, DelayRButton_r ,Off
    starttime := 25
    SetTimer, DelayRButton_r ,25
    tooltip,leftbutton    ; debug
return


RButton::
    if(starttime > 0)    ; if the left button was pressed IGNORE_TIME ago or less ignore right click
        return
    Send, {RButton}    ; else send right click
    tooltip,rightbutton    ; debug
return


DelayRButton_r:    ; this function runs every 25 ms until it reaches IGNORE_TIME then if sets starttime to 0 and rightclick works again
    starttime += 25
    if( starttime > IGNORE_TIME)
    {
        SetTimer,DelayRButton_r, Off
        starttime := 0
    }
return

还请记住,此代码可以轻松编辑为仅适用于特定应用程序/窗口。

【讨论】:

  • @Martin,我已经编辑了我的代码,以便仅在上一个热键是左键单击并且 Armin 提供了另一种解决方案时才等待。您能否就所提供的解决方案提供一些反馈?
  • @Robert,您修改后的代码正是我所需要的。 Armin 的代码是一个很好的教学工具。谢谢你们俩。
  • 如果答案有帮助,请单击白色复选标记将其变为绿色,从而“接受”该答案。谢谢!
  • 请通过单击白色复选标记将其变为绿色来“接受”答案。谢谢! Accepting answers
  • @Martin,单击问题旁边的白色复选标记以关闭问题并分配学分需要多少努力?
【解决方案2】:

根据您的描述,我假设您无法更改发送应用程序(即不是 AutoHotKey 脚本,但可能是编译后的 ahk.exe)

一旦您能够使用以下命令触发 AutoHotKey:

RButton::
    SoundBeep, 500,500
Return  

你可以试试这个代码:

SetTitleMatchMode = 2

#IfWinActive, Name of your Application
    $RButton::
       if (A_PriorHotkey = "LButton" AND A_TimeSincePriorHotkey < 400)
          Sleep, 1000
       Click, Right
    Return
#IfWinActive

您可以通过右键单击 AutoHotKey 图标,然后启动 Windows Spy 找到(发送或接收应用程序,取决于当时哪个应用程序处于活动状态)的名称。激活 Windows Spy 后,单击应用程序并查看应用程序的标题(或 ahk_class)。

警告我没有测试过这段代码!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-10
    • 1970-01-01
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-10
    相关资源
    最近更新 更多