这里是支持右键拖动的!
Hotkey, LButton, off
#IfWinActive ahk_class MozillaWindowClass
RButton & LButton::
Send X
Return
RButton::return
#IfWinNotActive ahk_class MozillaWindowClass
~$RButton::
Hotkey, LButton, on
while GetKeyState("RButton", "P") {
continue
}
Hotkey, LButton, off
Return
LButton::Send Y
Return
它手动处理RButton。当按下RButton 时,它会启用LButton 热键并等待RButton 被释放,然后再将其停用。 RButton 热键使用~,正常通过点击。
LButton 在开头被顶部的行禁用。
另一种方法是在热键的开头发送{RButton Down},在结尾发送{RButton Up}。
响应您的编辑,唯一拒绝 Autohotkey 发送事件的程序应该是那些依赖低级挂钩的程序......底部方法的真正问题是它只发送一次单击,而不是处理保持按钮。这种方法,以及分别向下和向上发送,都应该正确地做到这一点。
此答案底部描述的带有活动窗口的错误仍然存在,但这是#IfWin[Not]Active 的问题。
旧东西
见documentation on the ampersand(强调我的):
您可以通过在它们之间使用“&”来定义两个键(操纵杆按钮除外)的自定义组合。在下面的示例中,您将按住 Numpad0 然后按第二个键来触发热键:
Numpad0 & Numpad1::MsgBox You pressed Numpad1 while holding down Numpad0.
Numpad0 & Numpad2::Run Notepad
在上面的例子中,Numpad0 成为前缀键;但这也会导致 Numpad0 在被自己按下时失去其原始/原生功能。 为避免这种情况,脚本可以将 Numpad0 配置为执行新的操作,例如以下之一:
Numpad0::WinMaximize A ; Maximize the active/foreground window.
Numpad0::Send {Numpad0} ; Make the release of Numpad0 produce a Numpad0 keystroke. See comment below.
上述热键之一的存在会导致释放 Numpad0 以执行指示的操作,但前提是您在按住 Numpad0 时没有按任何其他键。
所以,按照那个例子:
#If WinActive("ahk_class MozillaWindowClass")
RButton & LButton::
Send X
Return
RButton::return
#If !WinActive("ahk_class MozillaWindowClass")
RButton & LButton::
Send Y
Return
RButton::Send {RButton}
注意RButton 需要一个在WinActive 中什么都不做的变体,至少在我的测试中(见下文):RButton::return
由于我使用的是 Autohotkey 标准,而不是 Autohotkey_L,因此我没有 #If,以上内容未经测试。以下我做了测试,它可以工作。
#IfWinActive ahk_class MozillaWindowClass
RButton & LButton::
Send X
Return
RButton::return
#IfWinNotActive ahk_class MozillaWindowClass
RButton & LButton::
Send Y
Return
RButton::Send {RButton}
我注意到一个有趣的错误是第二个(NotActive)变体偶尔适用于 Firefox:
- 另一个窗口处于活动状态
-
RButtondown已发送
- Firefox 未激活,因此处理第二个变体
- (
RButton 被按住,尽管延迟可能难以察觉,以毫秒为单位,直至无限)
- Firefox 激活
- (仍然按住)
-
RButton up 已发送,根据文档发送 RButton。因为 Firefox 在活动窗口检查和发送 RButton 之间的延迟时变为活动状态,所以 RButton 被发送到 Firefox。
当 Firefox 和另一个窗口都可见时,会发生这种情况,而另一个窗口在单击时是活动窗口。
我尝试通过在 RButton 热键中添加额外的 IfWinNotActive 检查来修复此错误,但它似乎不起作用。