首页 > 解决方案 > AutoHotKey - 按下鼠标滚轮时有选择地调用 AltTabMenu

问题描述

我目前使用以下脚本来使用鼠标滚轮切换应用程序:

MButton::AltTabMenu
WheelDown::AltTab
WheelUp::ShiftAltTab

这使我可以单击鼠标滚轮,然后滚动滚轮以选择所需的应用程序,然后再次单击以切换到它。

但是,有些应用程序需要我单击鼠标滚轮(即 SketchUp 才能进行轨道运行)。

仅当 SketchUp 应用程序位于前台时(即窗口具有焦点),我如何才能自动禁用/绕过这组宏?

根据官方文档,AltTabMenu 函数只有在直接与同一行的热键配对时才有效(即 MButton::AltTabMenu),所以我不能使用 WinGetTitle 和 IF 语句来选择性地调用 AltTabMenu。

目前,我在使用 SketchUp 时只是禁用了 AutoHotKey,但这很烦人,因为我的 AHK 脚本还包含我经常使用的其他几个快捷键/键重新映射。

感谢您的任何见解。

标签: autohotkeymousewheelalt-tab

解决方案


总结出色的 AHK 社区已经提供的解决方案,这是我对这个问题的看法:

MButton::Send , ^!{tab}  ; this sets wheel click to open the AltTab menu


#IfWinActive SketchUp ; you may need to adjust the window name here
MButton::return   ; ignore the hotkey defined above if SketchUp is active


#IfWinActive ahk_class MultitaskingViewFrame  ; Indicates that the alt-tab menu is present on the screen. The below hotkeys are used then to tab through the windows
WheelDown::Send, !{tab}
WheelUp::Send, +!{tab}
MButton::Send, {Enter}
#IfWinActive

推荐阅读