2012-11-09 103 views
1

我是新來的AutoHotKey,我試圖製作一個宏來關閉標籤頁上的瀏覽器窗口。我在Windows 7 Home Edition for x64上使用了Pale Moon(一種Firefox類型的瀏覽器)。中鼠標按鈕宏不起作用

我想通過按住鼠標右鍵關閉標籤窗口,然後單擊鼠標滾輪。我嘗試了幾個我下載的腳本(他們只需點擊鼠標中鍵),但他們什麼都不做;整個瀏覽器只是最小化(我相信這是鼠標滾輪的默認行爲)。

腳本駐留在我的桌面上。也許他們不工作,因爲他們沒有功能,雖然我在它們之前右鍵單擊它們並選擇Run。

下面是不起作用的腳本之一:

#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 

回答

0

對於實際的原因(保持右鍵的菜單功能),我會建議顛倒順序。先按中間按鈕,然後按下右按鈕。

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