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

后端 未结 1 378
你的背包
你的背包 2020-12-31 20:57

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

相关标签:
1条回答
  • 2020-12-31 21:16

    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);
    
    0 讨论(0)
提交回复
热议问题