✅ Wndproc is not receiving any messages when window is not focused
HI! I am trying to handle messages in WPF using WndProc like this:
When window is focused everything is working fine, but when I select another window, wndproc stop receiving any messages. How can I fix it?
16 Replies
What messages do you expect it to receive when it's not focussed?
From Wintab API
The Windows Ink thing? Why would that send you messages about what the stylus is doing when you're not the focussed application?
I have indepented stylus writing and mouse usage
"indepented"?
I mean you can use mouse and stylus in the same time
And problem starts when somebody select with mouse another app
I still don't follow. Windows has the concept of there being a single focussed application, which receives things like mouse movements and keyboard inputs. If you start typing, you don't want all of your windows to start responding to key presses. Likewise if you click on a window, you don't want the windows behind it to respond to the click
Imagine it this way, you have a main screen on which you are doing something and an additionally connected tablet with a screen. The application I am talking about is displayed on the tablet screen. On tablet screen there is no other window.
I know that I can get all the messages using winforms in the background but I am looking for less overcomplicated solution without using wpf and winforms at the same time
The message loop in winforms and WPF should be the same? I've done some googling, and I've yet to find a resource saying that two windows can receive input events at the same time in Windows
Have you seen anything which suggests this is possible?
I was testing some time ago some Wacom sdk and it was working
Windows doesn't know whether it's sending messges to a message pump which is being operated from windows or WPF
I know
I found today something named message-only window
Maybe it would work
only the focused window gets window input messages. but if you want to get window input messages even if ur not the focused window. you can use lowlevel hooks or rawinput
bcuz people ask for this frequently, i have made an example project https://github.com/QubitTooLate/Keylogging
GitHub
GitHub - QubitTooLate/Keylogging: Useful wrapper for Hot Keys and R...
Useful wrapper for Hot Keys and Raw Input in C#. Contribute to QubitTooLate/Keylogging development by creating an account on GitHub.
@Pandetthe
Thanks, I found another solution based on wintab api