Skip to content

Commit

Permalink
Improve right click on taskbar buttons behavior
Browse files Browse the repository at this point in the history
If the pointer is moved after right-clicking on taskbar buttons, it will no longer move to "Close Window" automatically.
  • Loading branch information
chaohershi committed Mar 27, 2019
1 parent 12ad2d8 commit 35a92c8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions CClose.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,23 @@ MouseIsOverTitlebar()

#If MouseIsOver("ahk_class Shell_TrayWnd") ; apply the following hotkey only when the mouse is over the taskbar
~RButton:: ; when right clicked
CoordMode, Mouse, Screen
MouseGetPos, xOld, yOld
Sleep 500 ; wait for the Jump List to pop up, n.b., this line also helps to provide a uniform waiting experience
Loop 6
MouseGetPos, xNew, yNew
CoordMode, Mouse, Window
if (Abs(xNew - xOld) < 8 && Abs(yNew - yOld) < 8) ; if mouse did not move much
{
if WinActive("ahk_class Windows.UI.Core.CoreWindow") ; if Jump List pops up (right clicked on taskbar app buttons)
Loop 6
{
WinGetPos, , , width, height ; get the size of the last found window (Jump List)
MouseMove, (width / 2), (height - 3 * width / 32), 1 ; move mouse to the bottom of the Jump List ("Close window")
break
if WinActive("ahk_class Windows.UI.Core.CoreWindow") ; if Jump List pops up (right clicked on taskbar app buttons)
{
WinGetPos, , , width, height ; get the size of the last found window (Jump List)
MouseMove, (width / 2), (height - 3 * width / 32), 1 ; move mouse to the bottom of the Jump List ("Close window")
break
}
Sleep 250 ; wait for more time
}
Sleep 250 ; wait for more time
}
Return

Expand Down

0 comments on commit 35a92c8

Please sign in to comment.