【问题标题】:Middle mouse button macros don't work鼠标中键宏不起作用
【发布时间】:2012-11-09 19:17:49
【问题描述】:

我是 AutoHotKey 的新手,我正在尝试制作一个宏来关闭选项卡式页面上的浏览器窗口。我在 Windows 7 Home Edition for x64 上使用 Pale Moon(一种 Firefox 类型的浏览器)。

我想通过按住鼠标右键,然后单击鼠标滚轮来关闭选项卡窗口。我已经尝试了几个我下载的脚本(它们只需单击鼠标中键即可工作),但它们什么也没做;整个浏览器都会被最小化(我相信这是鼠标滚轮的默认行为)。

脚本驻留在我的桌面上。也许它们不起作用,因为它们没有发挥作用,尽管我在尝试之前右键单击它们并选择了运行。

这是不起作用的脚本之一:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

MButton::
    CoordMode, Mouse, Screen
    MouseGetPos, x, y, WinUnderMouseID

    ;Get y position relative to the bottom of the screen.
    yBottom := A_ScreenHeight - y

    ; close tab in active window
    if (yBottom <= 40)
    {


        IfWinActive, ahk_class MozillaUIWindowClass
        {
        Send ^w
        return
        } else IfWinActive, ahk_class IEFrame
        {
        Send ^w
        }


    ; else send normal middle click
    } else {
        If GetKeyState("MButton") { ;The middle button is physically down
            MouseClick, Middle,,,0,D        ;middle button down
            KeyWait, MButton                ;to allow dragging
            MouseClick, Middle,,,,0,U       ;release middle button up
        } Else {
            MouseClick, Middle,,
        }

     }

return

【问题讨论】:

    标签: button browser tabs mouse autohotkey


    【解决方案1】:

    出于实际原因(保留右键菜单功能),我建议颠倒顺序。先按中间键,再按右键。

    MButton & RButton::
    Send, ^{F4}
    return
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-18
      • 2013-11-09
      • 2019-07-09
      • 1970-01-01
      • 2023-03-12
      • 2015-08-08
      相关资源
      最近更新 更多