Page 1 of 1

Mouse Click Through the Window Pinned On Top / On-screen Display (OSD)

Posted: 24 Jul 2023, 08:07
by NPerovic
Win+MButton Set/ reset the Window under the mouse cursor:
  • Always On Top
  • Transparent to 120
  • Let mouse click through the window.
Win+WheelUp Increase the opacity of the window under the mouse cursor.
Win+WheelDown Decreases the window opacity of the window under the mouse cursor.

When there's a window set click thorugh, alt+tab will restore the window to its original state.

Code: Select all

#Requires AutoHotkey 2.0.4

#MButton::
#WheelUp::
#WheelDown::
ClickThrough(hk?)
{
    SetWinDelay 0
    Static toggle := false, MouseWin := unset

	if hk ~= "S)#WheelUp|#WheelDown" { ; Win + WheelUp/ WheelDown to adjust the window opacity 
        WinID    := (MouseWin ?? MWin())
        curtrans := !(curtrans := WinGetTransparent(WinID)) ? 0 : curtrans
        newTrans := hk = "#WheelUp" ? Min(255, curtrans+8) : Max(0, curtrans-8)
        Return WinSetTransparent(newTrans, WinID)
	}

	if toggle := !toggle
         MouseWin := MWin()

	WinSetAlwaysOnTop(toggle, MouseWin)
	WinSetTransParent(toggle ? 120 : 255, MouseWin)
	WinSetExStyle(toggle ? "+32" : "-32", MouseWin)
	HotKey("!Tab", ClickThrough, toggle ? "On" : "Off") ; When there's a window set click thorugh, alt+tab will restore the window to its original state

	MWin() => (MouseGetPos(,, &_MWin), _MWin)
}
screenshots.gif
screenshots.gif (1.76 MiB) Viewed 1025 times

Re: Mouse Click Through the Window Pinned On Top / On-screen Display (OSD)

Posted: 28 Aug 2023, 15:05
by stefanwlb
Thanks for sharing this is really helpful!

Re: Mouse Click Through the Window Pinned On Top / On-screen Display (OSD)

Posted: 18 Mar 2024, 23:30
by Haris00911
This is an amazing script, I'm so glad I found your thread on Google while searching for this exact functionality in the PowerToys version of "Always on Top" (which doesn't exist by the way). Thank you for sharing!

Re: Mouse Click Through the Window Pinned On Top / On-screen Display (OSD)

Posted: 19 Mar 2024, 14:53
by kunkel321
Very cool script! I'm definitely going to hold on to this one. Thanks for making and sharing it!!! :D