How can I raise a mouse event in WPF / C # with specific coordinates?

I would like to raise a mouse event (click, mousedown or mouseup) by clicking the user anywhere in the WPF window and translating it to a known difference, for example. click on x, y, raise the click event on x + 100, y + 100.

The main problem is that there is a display monitor that physically moves relative to the superimposed touch screen. Instead of recalibrating the touch screen with each movement, I would like to add a translation offset to the click event.

I looked at the Win32 API for mouse_event and its replacement function SendInput. I admit that I am lost because I am not very familiar with the API.

Of course, this is a simple problem to solve, but I can’t find the sample code anywhere I can find a solution from. Any help, pointers or solid examples of how to add this to my code behind will be appreciated.

Thanks Mark

+7
source share
1 answer

Win32 API will not work with WPF, this may help

// Copied the snippet of code from the link above, just to help future readers MouseEventArgs e = new MouseEventArgs(Mouse.PrimaryDevice, 0); e.RoutedEvent = Mouse.MouseEnterEvent; youUIElement.RaiseEvent(e); // Or InputManager.Current.ProcessInput(e); 
+8
source

All Articles