❔ WPF Window click-thru/non-clickable
Hey, how is it possible to make a WPF Window click-thru/non-clickable. I don't want to highlight or click on it in any way. The window is for an overlay, so I needs to be uninteractable, so you don't click it accidently.
I already tried the following without success:
1. Using SetWindowLong
This didn't work, and its still clickable for some reason. Is it because im trying to do it from inside the WPF windows own code?
2. IsHitTestVisible
I tried setting
IsHitTestVisible
to false
, both in the XAML and after instancing the window. Still clickable...
Any help is appreciated, as I can't seem to find anything online that is not the methods listed above.
Thanks22 Replies
Here's what I've done in the past to set windows as transparent
style is gotten from
Differences I see are, you're fully setting, not appending, and not using
WS_EX_Layered
Hope it helps!
Possibly also check if the PInvokes are failing tooI'm assuming this is like a HUD assist or other type application; so that you can decorate various parts of the HUD decorator without impacting/interacting with the game?
Yes, it just needs to stay on top of the application 🙂
Hi, do I need some special package for this or?
WindowStylesEx isnt a type and also HWND is the type IntPtr in C#, so I'm not really sure if your code is for a nuget package or smth
So if they violates the game TOS it can't really be discussed here; but this isn't something that wpf handles out of the box; and iirc a lot of it involves poorly documented windows apis.
Its not violating any TOS
I don't know the poorly documented windows apis myself; other then they're poorly documented.
hm :/
it is a nuget package but can easily be inferred what is what. like HWND is just an IntPtr
and WindowStylesEx is an enum that has all the values, i believe in C++ they're constants
(32U is the same as your
0x00000020
btw)so layered is
0x00080000
so instead, you could just substitute them out as
then just check if sr != 0 as a success check
Vanara.PInvoke has their method summaries scraped from https://learn.microsoft.com/en-us/windows/win32/api/ i believeSome processes run elevated, so the method SetWindowLong can fail if your process is not admin too
Seems WPF is a type of exception to this, I found a stackoverflow post about it here
Stack Overflow
Making a WPF window click-through, but not its controls
First of all I want to define what I mean by transparent to clicks in the text bellow: It means the clicks go through my window without any processing, directly to whichever window is bellow it. I ...
Hm I tried rewriting the one you send yesterday to plain C# types, but it didn't work, but I was still using the hex values, I will try with the plain integer ones, I also tried using Vanara.PInvoke since they have the types your example used, but didn't work either. My application runs as adminstrator so it shouldn't be a problem with the elevated thing
Stack Overflow
Making a WPF window click-through, but not its controls
First of all I want to define what I mean by transparent to clicks in the text bellow: It means the clicks go through my window without any processing, directly to whichever window is bellow it. I ...
What It basically does Is create a transparent window.(Click through and Invisble). But controls are visible and not-click through. Or you can try How to create a semi transparent window in WPF that allows mouse events to pass through
I dont need controls or anything on the overlay/window, but I'll try it
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.