Last active
August 29, 2020 07:11
-
-
Save DavidJCobb/ee4b897257f79fd9b748615ad5945874 to your computer and use it in GitHub Desktop.
Tired of Windows 10 notifications blocking access to toolbars, buttons, and Twitch chat textboxes in the lower-right corner of the screen? Sick of how the darn things block an invisible strip of space above them, too? This should fix that.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
; Make Windows notifications semitransparent, and allow the user to click through | |
; all but their rightmost portion (so as to keep the close/dismiss button usable). | |
; | |
#Persistent | |
#SingleInstance | |
#NoEnv | |
#Warn | |
SendMode Input | |
SetWorkingDir %A_ScriptDir% | |
ListVars | |
CoordMode, Mouse, Screen | |
OnExit, lExit | |
; | |
; We need to store the window ID because MouseGetPos can't "see" a click-through | |
; window; if we set the notification window to click-through and don't store it, | |
; we'll lose it forever (unless the user kills its process). | |
; | |
giWindowID := 0 | |
SetTimer, lForcePosition, 100 | |
Return | |
lForcePosition: | |
global giWindowID | |
; | |
; If the process has restarted during the Windows session, AutoHotKey can't retrieve it by | |
; process name, window title, or window class. I don't know why that happens. Anyway, | |
; MouseGetPos is always able to find it, so... | |
; | |
MouseGetPos, iMouseX, iMouseY, iIDMouse, | |
WinGetTitle, sWindowName, ahk_id %iIDMouse% | |
WinGet, sProcessName, ProcessName, ahk_id %iIDMouse% | |
if (sProcessName = "ShellExperienceHost.exe") and (sWindowName = "New notification") { | |
if (giWindowID == 0) { | |
giWindowID := iIDMouse | |
; | |
; We haven't found a notification window yet, so store this one. | |
} | |
} | |
if (giWindowID) { | |
WinGetPos iX, iY, iWidth, iHeight, ahk_id %giWindowID% | |
iEstimatedXButton := iX + iWidth - 64 ; Screen-relative right edge of the "close" button, estimated. | |
; This is a hideous hack... We can't make part of the window pass-through; we have to make the | |
; whole thing pass-through. | |
; | |
if (iMouseX < iEstimatedXButton) { | |
WinSet, ExStyle, +0x20, ahk_id %giWindowID% ; 0x20 = WS_EX_CLICKTHROUGH | |
WinSet, Transparent, 200, ahk_id %giWindowID% | |
} else { | |
WinSet, ExStyle, -0x20, ahk_id %giWindowID% ; 0x20 = WS_EX_CLICKTHROUGH | |
WinSet, Transparent, OFF, ahk_id %giWindowID% | |
} | |
} | |
SetTimer, lForcePosition, 100 | |
Return | |
lExit: | |
if (giWindowID) { | |
WinSet, ExStyle, -0x20, ahk_id %giWindowID% ; 0x20 = WS_EX_CLICKTHROUGH | |
WinSet, Transparent, OFF, ahk_id %giWindowID% | |
} | |
; | |
; A script with an OnExit subroutine will not terminate unless the subroutine uses ExitApp | |
; | |
; "Where we're going, we don't NEED intuitive behavior." | |
; - AutoHotKey tagline, probably | |
; | |
ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment