Some applications absorb mouse events made by stylus so that I can't hook them

Viewed 104

My ultimate purpose is getting mouse move event from outside of my main window, and distinguish it was from mouse or stylus.

Before I ask my question, I want to notice what I already knew.

I used SetWindowsHookEx to hook mouse events. The value - MSLLHOOKSTRUCT.dwExtraInfo I received, when I use stylus pen, it came as 0xFF515712. So I was able to distinguish mouse move and stylus move. At this time, there was nothing wrong.

The problem is that mouse event messages doesn't be raised when my stylus is on any other active window(ex. Chrome). There wasn't any message so nothing to confirm and analyze. But the stylus pointer(cursor) was on my desktop wallpaper, or on the main app, everything went well as I mentioned.

In my guessing, Windows 10 treat stylus movements on web browsing as another events not as mouse events. I want to hook them, but I don't know what kind of event they are.

The important thing you need to know is that this issue is not for every mouse event, but just for events from stylus device.

I really tried to search the solution, but there is no way but ask to you genius people. Please help me, you people already helped me a lot in many stack overflow pages, but I need you more, and your answering may help this project -> https://github.com/ladofa/thepen


Additional info.

I found specific programs that absorb mouse events from stylus.

  • All browsers (Chrome, Edge, Internet Explorer) except the title bar of them.
  • Calculator
  • VSCode
1 Answers

Probably relevant, from https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644986(v=vs.85) ("LowLevelMouseProc callback function"):

If nCode is greater than or equal to zero, and the hook procedure did not process the message, it is highly recommended that you call CallNextHookEx and return the value it returns; otherwise, other applications that have installed WH_MOUSE_LL hooks will not receive hook notifications and may behave incorrectly as a result. If the hook procedure processed the message, it may return a nonzero value to prevent the system from passing the message to the rest of the hook chain or the target window procedure.

(emphasis added)

Related