当在范围内的 window 中使用 "trigger" 时,AHK 无法执行。有没有办法让AHK"greedier"?
AHK fails to execute when the "trigger" is used in the window that is in scope. Is there a way to make AHK "greedier"?
我正在尝试使用鼠标的 XButton1
和 XButton2
在 win10 上的虚拟桌面之间切换。
到目前为止,一切正常,除了当我将 Firefox 作为我的活动范围时,显然这些按钮用于 forward/backward(问题出现在每个 window使用这些按钮做某事)。
这似乎可以防止 AHK 注意到我使用了配置的触发器或没有执行脚本(我认为这不太可能)。
对于 Firefox,我通过将 mousbutton.4th.enable
和 mouse button.5th.enable
设置为 false
来禁用 [about: config](about config) 页面中这些按钮的使用找到了解决方法,但是这并不适用于所有情况,因为并不总是有办法禁用这些按钮。
我也尝试过使用鼠标滚轮倾斜按钮,但默认用法哦,它们在我使用的程序中更为常见。
这是我正在使用的脚本。
# NoEnv; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
XButton1::Send ^#{Left}
XButton2::Send ^#{Right}
return
如果有人有解决方法或完全不同的想法(例如完全明显的 Win10 feature/setting 我失踪了)我会非常高兴。
您可以在脚本中为这两个键定义自定义组合
例如
XButton1 & LButton::return ; do nothing
; or another action:
; XButton1 & LButton:: Run notepad
XButton1::Send ^#{Left}
XButton2 & a::return
XButton2::Send ^#{Right}
这样按键就失去了它们在程序中的原生功能。
编辑:
如果一个程序是 运行 管理员权限,那么 AHK 将不会拦截按键,这很可能是这个问题背后的原因。
如果是这种情况,请尝试 运行 AHK 脚本作为管理员,方法是将此添加到 auto-execute section(脚本顶部):
; If the script is not elevated, relaunch as administrator and kill current instance:
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try ; leads to having the script re-launching itself as administrator
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
当需要使用 AHK 时,来自 user3419297 的 可以完美运行。
实现相同结果的另一种方法是使用 X-Mouse Button Control.
只需将鼠标按钮 4/5 设置为 Simulated Keys:
和 {CTRL}{LWIN}{RIGHT}
和 {CTRL}{LWIN}{LEFT}
。
我正在尝试使用鼠标的 XButton1
和 XButton2
在 win10 上的虚拟桌面之间切换。
到目前为止,一切正常,除了当我将 Firefox 作为我的活动范围时,显然这些按钮用于 forward/backward(问题出现在每个 window使用这些按钮做某事)。
这似乎可以防止 AHK 注意到我使用了配置的触发器或没有执行脚本(我认为这不太可能)。
对于 Firefox,我通过将 mousbutton.4th.enable
和 mouse button.5th.enable
设置为 false
来禁用 [about: config](about config) 页面中这些按钮的使用找到了解决方法,但是这并不适用于所有情况,因为并不总是有办法禁用这些按钮。
我也尝试过使用鼠标滚轮倾斜按钮,但默认用法哦,它们在我使用的程序中更为常见。
这是我正在使用的脚本。
# NoEnv; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
XButton1::Send ^#{Left}
XButton2::Send ^#{Right}
return
如果有人有解决方法或完全不同的想法(例如完全明显的 Win10 feature/setting 我失踪了)我会非常高兴。
您可以在脚本中为这两个键定义自定义组合 例如
XButton1 & LButton::return ; do nothing
; or another action:
; XButton1 & LButton:: Run notepad
XButton1::Send ^#{Left}
XButton2 & a::return
XButton2::Send ^#{Right}
这样按键就失去了它们在程序中的原生功能。
编辑:
如果一个程序是 运行 管理员权限,那么 AHK 将不会拦截按键,这很可能是这个问题背后的原因。
如果是这种情况,请尝试 运行 AHK 脚本作为管理员,方法是将此添加到 auto-execute section(脚本顶部):
; If the script is not elevated, relaunch as administrator and kill current instance:
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try ; leads to having the script re-launching itself as administrator
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
当需要使用 AHK 时,来自 user3419297 的
实现相同结果的另一种方法是使用 X-Mouse Button Control.
只需将鼠标按钮 4/5 设置为 Simulated Keys:
和 {CTRL}{LWIN}{RIGHT}
和 {CTRL}{LWIN}{LEFT}
。