How can I raise a mouse event in WPF / C# with specific coordinates?
I'd like to raise a mouse event (a click, mousedown, or mouseup) by taking a user's click anywhere in a WPF window and translating it by a known difference, e.g. click at x,y, raise the click event at x+100, y+100.
The underlying problem is that there's a display monitor that physically moves relative to an overlaying touch screen. Rather than recalibrating the touchscreen with every move, I'd like to add the translat开发者_如何学编程ion offset to the click event.
I've looked at the Win32 API for mouse_event and its superseding function, SendInput. I admit I'm lost as I'm not very familiar with the API.
Surely this is a simple problem to solve, but I can't find example code anywhere that gets me to where I can implement a solution. Any help, pointers, or solid examples of how to add this to my code behind would be appreciated.
Thanks Mark
Win32 API won't work with WPF, this link might 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);
精彩评论