; This code is released under the Creative Commons 3.0 Attribution Non-Commercial ; Share Alike license, found at http://creativecommons.org/licenses/by-nc-sa/3.0/ ; You can share the code and you can change the code if wish, ; but the license must remain in effect and you must attribute the original source: ; http://www.ocellated.com/2009/06/04/taskbar-overlord/ ; You cannot use the work for any commercial purpose. ; While the code here has been tested repeatedly under different scenarios and is ; believed to work properly, by using it you agree to hold its maker harmless from ; any damages. This code is released WITHOUT ANY WARRANTY; without even ; the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #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. ;Handle left clicks on Windows 7 Taskbar by sending ctrl left click ;so that when multiple instances of a program exist, the last used ;window is restored instead of seeing the thumbnail previews ;***************************************************************** LButton:: CoordMode, Mouse, Screen MouseGetPos, x, y, WinUnderMouseID ;Get y position relative to the bottom of the screen. yBottom := A_ScreenHeight - y ;Send a control left click if clicking on a taskbar item if yBottom <= 40 { Send ^{Click %x% %y%} ;Else, send normal left click } else { ;If left button is physically down If GetKeyState("LButton", "P") { MouseClick, left,,,1,0,D ;mouse button down KeyWait, LButton ;to allow dragging the mouse MouseClick, left,,,1,0,U ;release mouse button up } Else { MouseClick, left, %x%, %y% } } Return ;Handle middle clicks on Windows 7 Taskbar to close all windows for a given icon ;******************************************************************************** MButton:: CoordMode, Mouse, Screen MouseGetPos, x, y, WinUnderMouseID ;WinActivate, ahk_id %WinUnderMouseID% ;Get y position relative to the bottom of the screen. yBottom := A_ScreenHeight - y ; Close taskbar program on middle click, if click on a taskbar icon if yBottom <= 40 { BlockInput On Send, +{Click %x% %y% right} ;shift right click Sleep, 100 Send, C ;send c which is Close All Windows WinWaitNotActive, ahk_class Shell_TrayWnd,, 0.5 ; wait for save dialog, etc If ErrorLevel = 1 Send, {Escape} ;hides context menu if no program icon clicked. BlockInput Off ; 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