Win 10: How can I make an window be always on top but non-interactive (clicks go through)?

I'm trying to set up a small window in my screen that is always on top but at the same time "ghosted" (not sure about the term), meaning I can't interact or activate it and any mouse click would go through it.

To be more specific I want VLC playing videos in a small window on top of a videogame, without it preventing me from interacting in that area of the screen.

So far I have been trying WinWarden (an AHK script) and managed to set the position and the size of the window but I can't figure out how to make the window non-interactable (In theory WinWarden has the capacity to do that but I haven't managed to make it work).

Any idea on how to do this or where to start?

2

2 Answers

In case someone needs something similar, I managed to make it by adding a couple lines of code to the WinWarden script from the information in this post

1

WinKey+Alt+Space makes the current window Always On Top, Click-through, and Transparent.

  • You can set a custom transparency value like Montage(128), but I've found 187 seems to be a good compromise on light and dark backgrounds:
Montage(trans := 187){ WinSet AlwaysOnTop, OFF, A ; Tricky! A Style value cannot be negative. WinGet ExStyle, ExStyle, A ; If it would be negative, it is not applied. WinSet ExStyle, -0x80020, A ; Therefore, if the style value has not changed, WinGet Normal, ExStyle, A ; then it never had a Style to begin with. if (ExStyle = Normal){ WinSet AlwaysOnTop, On, A ; Apply styles. WinSet ExStyle, +0x80020, A WinSet Transparent, % trans, A } return
}
  • Better comments and refactor bitwise operations:
    #!Space:: Montage()
    Montage(trans := 187){ WinExist("A") ; Last Found Window WinGet ExStyle, ExStyle ; Store the Extended Styles in the variable ExStyle. if (ExStyle & 0x80028) == 0x80028 { ; WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOPMOST WinSet AlwaysOnTop, Off ; Uses SetWindowPos instead of SetWindowLong. WinSet ExStyle, -0x80028 ; Remove clickthough and transparency. } else { WinSet AlwaysOnTop, On ; Although WS_EX_TOPMOST (0x8) is an ExStyle, it requires SetWindowPos. WinSet ExStyle, +0x80028 ; Add clickthough and transparency. WinSet Transparent, % trans ; Set window transparency value. }
    }
  • Faster, improved version, fixing race conditions:
    Montage(trans := 187){ WinExist("A") ; Last Found Window WinSet AlwaysOnTop, OFF ; Tricky! A Style value cannot be negative. WinGet ExStyle, ExStyle ; If it would be negative, it is not applied. WinSet ExStyle, -0x80020 ; Therefore, if the style value has not changed, WinGet Normal, ExStyle ; then it never had a Style to begin with. if (ExStyle = Normal){ WinSet AlwaysOnTop, On ; Apply styles. WinSet ExStyle, +0x80020 WinSet Transparent, % trans }
    }

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like