Autohotkey B按钮后延迟B按钮

Autohotkey B按钮后延迟B按钮,autohotkey,Autohotkey,我运行一个应用程序,该应用程序会删除一个在LButton之后过快的RButton。解决方案可能是运行以下操作 ~LButton:: ; pass through, set A_PriorHotkey return #If A_PriorHotkey = LButton && A_TimeSincePriorHotkey < minDelay RButton:: ~LButton:;通过,设置一个\u优先级热键 返回 #如果A_Pr

我运行一个应用程序,该应用程序会删除一个在LButton之后过快的RButton。解决方案可能是运行以下操作

~LButton::                    ; pass through, set A_PriorHotkey
return

#If A_PriorHotkey = LButton && A_TimeSincePriorHotkey < minDelay
RButton:: 
~LButton:;通过,设置一个\u优先级热键
返回
#如果A_PriorHotkey=LButton&&A_TimeSincePriorHotkey
但是我没有运气写最后一行和下面几行,所以如果#if为false,则发送正常的MButton down和RButton up,如果#if为true,则发送RButton down和RButton up


提前感谢。

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

一旦您能够使用以下命令触发自动热键:

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
SetTitleMatchMode=2
#IfWinActive,应用程序的名称
$RButton::
如果(A_PriorHotkey=“LButton”和A_TimeSincePriorHotkey<400)
睡吧,1000
点击,对吗
返回
#IfWinActive
通过右键单击自动热键图标,然后启动Windows Spy,可以找到(发送或接收应用程序,取决于当时哪个应用程序处于活动状态)的名称。在Windows Spy处于活动状态时,单击应用程序并查看应用程序(或ahk_类)的标题


警告:我尚未测试此代码

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

基本上,我们所做的是左键单击,直到到达某个时间(在本例中为1000毫秒->忽略时间),同时忽略右键单击,当时间结束时,右键单击再次激活

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

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

首先,您需要知道是否可以“捕获”来自应用程序的RButton。请尝试:RButton::SoundBeep,500500以查看是否可以通过这种方式触发自动热键,或者您可能需要使用VK/SC代码。RButton::SoundBeep,500500在应用程序中工作。回答1@Robert:谢谢。不是所有右键单击都应该延迟,只是那些在左键单击后立即延迟的右键单击。@Armin:谢谢。您的代码将在指定时间内终止所有右键单击。我需要有右键点击火灾后的时间段,而不是消失。我想我可以调整你的方法来做到这一点。好的,所以你只想延迟左键单击之后的右键单击。所有其他右键点击都应该在un DELAY上传递@Martin,我已经编辑了我的代码,只在上一个热键是左键单击并且Armin提供了另一个解决方案时才等待。您能就提供的解决方案给出一些反馈吗?@Robert,您修订的代码正是我所需要的。阿明的代码是一个很好的教学工具。谢谢你们。如果答案有帮助,请点击白色复选标记将其变为绿色,以“接受”该答案。非常感谢。请单击白色复选标记将其变为绿色,以“接受”答案。谢谢大家!@Martin,点击问题旁边的白色复选标记来结束问题并分发学分需要付出多少努力?