1

我是 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
4

1 回答 1

1

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

MButton & RButton::
Send, ^{F4}
return
于 2012-11-10T10:53:51.857 回答