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

Post your working scripts, libraries and tools.
User avatar
NPerovic
Posts: 35
Joined: 31 Dec 2022, 01:25
Contact:

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

24 Jul 2023, 08:07

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 894 times
Last edited by NPerovic on 10 Apr 2024, 15:02, edited 1 time in total.
✨ Dark Theme for Everything
✨ Other Scripts

stefanwlb
Posts: 4
Joined: 28 Aug 2023, 14:13

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

28 Aug 2023, 15:05

Thanks for sharing this is really helpful!
User avatar
Haris00911
Posts: 2
Joined: 18 Mar 2024, 23:22
Contact:

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

18 Mar 2024, 23:30

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!
User avatar
kunkel321
Posts: 1061
Joined: 30 Nov 2015, 21:19

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

19 Mar 2024, 14:53

Very cool script! I'm definitely going to hold on to this one. Thanks for making and sharing it!!! :D
ste(phen|ve) kunkel

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: wineguy and 50 guests