From 35a92c8dced8bb6fe7c510eb7818e87c1d93d4a0 Mon Sep 17 00:00:00 2001 From: Chaohe Shi Date: Wed, 27 Mar 2019 04:14:19 -0400 Subject: [PATCH] Improve right click on taskbar buttons behavior If the pointer is moved after right-clicking on taskbar buttons, it will no longer move to "Close Window" automatically. --- CClose.ahk | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/CClose.ahk b/CClose.ahk index b57ffe9..00ff6b1 100644 --- a/CClose.ahk +++ b/CClose.ahk @@ -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