模拟多个鼠标事件

发布于 2024-12-05 05:17:14 字数 825 浏览 1 评论 0原文

我正在尝试创建一个 UI,无需鼠标即可与普通 WPF 控件进行交互。我想支持多个光标,因此使用任何常规输入模拟(例如 SendInput)都不起作用。我还尝试隔行扫描 SendInput 消息来模拟鼠标光标,但这也不起作用(只有一个鼠标输入)。我还有一个限制,就是我不想使用 Windows MultiPoint。 当我检测到光标位置位于控件上方时,我尝试通过鼠标事件将事件发送到控件(在 Button 上进行测试),使用: MouseEnterEventMouseLeaveEventMouseMoveMouseDownEventMouseUpEvent。但除了 MouseDownEvent 之外,它似乎都不起作用。 以下是我如何发送 MouseEnterEvent 的示例:

System.Windows.Input.MouseEventArgs e =
    new System.Windows.Input.MouseEventArgs(System.Windows.Input.Mouse.PrimaryDevice, DateTime.Now.Millisecond);
e.RoutedEvent = System.Windows.Input.Mouse.MouseEnterEvent;
elementUnderCursor.RaiseEvent(e);

其中 elementUnderCursorUIElement

I'm attempting to create a UI where I interact with normal WPF controls without the mouse. I want to support multiple cursors so using any regular input simulation (such as SendInput) doesn't work. I also tried interlacing SendInput messages to simulate to mouse cursors but that didn't work either (only got one mouse input). I also have the constraint that I do not want to use Windows MultiPoint.
I've tried sending events to the controls (testing it on Button) through mouse events when I detect my cursor position is above the controls using: MouseEnterEvent, MouseLeaveEvent, MouseMove, MouseDownEvent and MouseUpEvent. But except for the MouseDownEvent, none of it seems to work.
Here is an example of how I send the MouseEnterEvent:

System.Windows.Input.MouseEventArgs e =
    new System.Windows.Input.MouseEventArgs(System.Windows.Input.Mouse.PrimaryDevice, DateTime.Now.Millisecond);
e.RoutedEvent = System.Windows.Input.Mouse.MouseEnterEvent;
elementUnderCursor.RaiseEvent(e);

Where elementUnderCursor is a UIElement.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白龙吟 2024-12-12 05:17:14

我认为我希望我的 multimose kinect 应用程序有同样的功能,但是如果您有一个模拟鼠标驱动程序,您只需弄清楚如何告诉应用程序该鼠标驱动程序而不是您的 USB 鼠标或 ps/ 发生了事件2 鼠标驱动程序。
例如,
发送 mousedown 和 up 事件来模拟鼠标 #1、#2 的鼠标单击。另外,更新鼠标#1、#2 的鼠标位置。
我对上述内容的推理是我希望它可以通过在后台运行与上述程序类似的程序作为服务来在任何应用程序中工作。

I think that i wanted the same thing for my multimose kinect app be but if you have an emulated mouse driver you would just have to figure out how to tell the app that an event happened with that mouse driver instead of your usb mouse or ps/2 mouse driver.
For instance,
send the mousedown and up event to simulate mouse click for mouse #1,#2. Also, update mouse positon for mouse #1,#2.
My reasoning for the above is i wanted it to work in any application by running a similar program to the above program in the background as a service.

请止步禁区 2024-12-12 05:17:14

更新 dsf 可用于模拟虚拟鼠标设备,我正在使用 kinect 处理多个鼠标项目,因此请查看以下站点的当前进度:http ://kinectmultipoint.codeplex.com
请注意,多个鼠标驱动程序不可能在一夜之间构建完成。
另外,下载windows ddk来模拟鼠标设备。必须根据您的场景更改 testgenerichid.wsf 脚本,但这是可能的。

Update dsf works for simulating virtual mouse devices im working on a multiple mouse project with kinect so please look at the current progress at the site: http://kinectmultipoint.codeplex.com.
be warned multiple mouse drivers cant be built overnight.
also, download the windows ddk to simulate the mouse devices. the testgenerichid.wsf script has to be changed for your scenario but its possible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文