如何在 WPF / C# 中使用特定坐标引发鼠标事件?
我想通过用户在 WPF 窗口中的任意位置单击并按已知差异进行转换来引发鼠标事件(单击、鼠标向下或鼠标向上),例如在 x,y 处单击,在 x+ 处引发单击事件100,y+100。
根本问题是显示监视器相对于覆盖的触摸屏进行物理移动。我不想每次移动都重新校准触摸屏,而是想将平移偏移添加到点击事件中。
我研究了 mouse_event 的 Win32 API 及其替代函数 SendInput。我承认我迷失了,因为我对 API 不太熟悉。
当然,这是一个需要解决的简单问题,但我无法在任何地方找到示例代码来帮助我实现解决方案。任何有关如何将其添加到我的代码后面的帮助、指针或可靠示例将不胜感激。
谢谢 标记
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 translation 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Win32 API 不适用于 WPF,此链接 可能有帮助
Win32 API won't work with WPF, this link might help