Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8269203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:08:38+00:00 2026-06-08T06:08:38+00:00

[Edit] Here’s what I’ve gleaned about mouse input handling thus far. Note that I’ve

  • 0

[Edit] Here’s what I’ve gleaned about mouse input handling thus far. Note that I’ve learned this via a bunch of different sources and via experimentation, so don’t take this as gospel:
1) Mouse event originates with mouse move
2) SetWindowsHookEx(WH_MOUSE_LL) handler LowLevelMouseProc sees event first
3) OS/app framework handles Mouse event at some high level (mouse cursor moves)
4) WM_INPUT event is picked up by app event queue and handled by WndProc (although handling at this time does not stop mouse cursor from moving in step 3).
5) Message is dispatched via ComponentDispatcher
6) PreviewMouseMove and MouseMove events are triggered and may be handled by the app.

Based on this, I think the only way to ensure that the mouse cursor doesn’t move is to filter via WH_MOUSE_LL. Of course, as I’ve mentioned earlier in this post, there isn’t sufficient information at this point to know which device this mouse event is coming from, so it’s all or nothing filtering, which doesn’t meet my requirements.


[Edit] I’ve verified that I’m able to drop events by hooking WH_MOUSE_LL and returning a value larger than 0 from the handler. Now I just need to figure out how to match a mouse event generated at the WH_MOUSE_LL level with events coming from my device…

I did try returning a value greater than 0 from WndProc. The event was still processed by my app.


I’m trying to integrate a rotary input device that’s based upon the Y-axis of a mechanical USB mouse. I’d like for this device to behave solely as a raw input device and for the normal mouse move events generated by the device (at least in the context of my application) to be dropped.

So far, I’ve been able to hook WndProc into my WPF application MainWindow using WindowIteropHandler and AddHook. I’m able to receive WM_INPUT events and filter those for mouse events from my specific USB VID/PID device (sufficient for my needs).

I would expect that marking the message as handled and returning 0 would cause the message to not be propagated to the rest of the WPF window, but that’s not the case… I’m still getting MouseMove events when I move my device. Here’s my code (simplified to remove processing the WM_INPUT message, but still exhibits the same issue):

 public partial class MainWindow : Window
{
    private const int WM_INPUT = 0x00FF;

    public MainWindow()
    {
        InitializeComponent();
    }

    public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
    {
        if (msg == WM_INPUT)
        {
            // TODO - figure out why this doesn't halt further processing of this handled event
            handled = true;
        }
        return IntPtr.Zero;
    }

    [StructLayout(LayoutKind.Sequential)]
    internal struct RAWINPUTDEVICE
    {
        [MarshalAs(UnmanagedType.U2)]
        public ushort usUsagePage;
        [MarshalAs(UnmanagedType.U2)]
        public ushort usUsage;
        [MarshalAs(UnmanagedType.U4)]
        public int dwFlags;
        public IntPtr hwndTarget;
    }

    private const int RIDEV_INPUTSINK = 0x00000100;

    [DllImport("User32.dll")]
    extern static bool RegisterRawInputDevices(RAWINPUTDEVICE[] pRawInputDevice, uint uiNumDevices, uint cbSize);

    private void Window_SourceInitialized(object sender, EventArgs e)
    {
        WindowInteropHelper helper = new WindowInteropHelper(this);
        HwndSource source = HwndSource.FromHwnd(helper.Handle);
        RAWINPUTDEVICE[] rid = new RAWINPUTDEVICE[1];

        rid[0].usUsagePage  = 0x01;
        rid[0].usUsage      = 0x02;
        rid[0].dwFlags      = RIDEV_INPUTSINK; 
        rid[0].hwndTarget   = source.Handle;
        RegisterRawInputDevices(rid, (uint)rid.Length, (uint)Marshal.SizeOf(rid[0]));

        source.AddHook(WndProc);
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        e.Handled = true;
    }

    private void button1_MouseMove(object sender, MouseEventArgs e)
    {
        e.Handled = true;
    }
}

Anyone know how to dequeue or otherwise block a mouse event that I’ve handled in WndProc from being propagated to MainWindow?

TIA!

-Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:08:40+00:00Added an answer on June 8, 2026 at 6:08 am

    After long hours of Googling, it looks like someone else has already described and solved what I’m trying to do using a UMDF: http://oblita.com/Interception

    I was hoping I wouldn’t have to go there, but it’s looking like this is the only way to actually intercept events coming from a particular device.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
Edit: Here is the new code: $(#normalcontent).hide(fast).load($this.attr(href) + #normalcontent,,function(){ $(this).slideDown(normal); $(this).find(img).each(function(){ if($(this).hasClass(large)) { var
What tools are used to create installers like this: EDIT: Here's a full tutorial:
Edit: Here's a truly simple example. Motivation for this example below. This compiles: {-#
Edit : Here is a much more simpler example of this issue (i've deleted
EDIT: Here is the edited control file (control.ascx): <%@ Control Language=C# AutoEventWireup=true CodeFile=Sale.ascx.cs Inherits=Enmasse.Modules.Demo_Enmasse.Sale
EDIT: Here's a create script for the table minus the constraints on the keys
When inserting values into my table what do I edit here? Do I delete
When a user links to link it redirects to edit.php - here's an example:
I'm looking to analyze and compare the following `signals': (Edit: better renderings here: oscillations

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.