射击MouseLeftButtonDown事件编程 [英] Firing MouseLeftButtonDown event programmatically

查看:341
本文介绍了射击MouseLeftButtonDown事件编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,手动火灾对WPF控件的MouseLeftButtonDown事件编程,因为我现在用的是微软的Surface SDK,它不火的MouseLeftButtonDown事件,但ContactDown事件。基本上我试图推MouseLeftButtonDown事件下到控制,断火在控制正确的行为,在处理一个ContactDown事件。

I'm trying to manually fire a MouseLeftButtonDown event on a WPF control programmatically, as I am using the Microsoft Surface SDK, which does not fire MouseLeftButtonDown events, but ContactDown events. Basically I'm trying to push the MouseLeftButtonDown event down to the control, to fire off the correct behavior on the control, while handling a ContactDown event.

我猜我必须以某种方式使用的RaiseEvent方法上的控制与MouseButtonEventArgs要做到这一点,但我遇到了一些麻烦搞清楚的参数。

I'm guessing I have to somehow use the RaiseEvent method on the control to do this with MouseButtonEventArgs, but I'm having some trouble figuring out the parameters.

在您的帮助谢谢!

推荐答案

您可以伪造使用Win32互操作鼠标和键盘事件。探讨 MSDN /的pinvoke.net

You can spoof mouse and key events using Win32 interop. Investigate the SendInput function on MSDN/pinvoke.net.

请注意,这将导致系统和其他应用程序想想鼠标竟然被点击。如果你只是想发起一个WPF事件,尝试的RaiseEvent(新RoutedEventArgs(UIElement.MouseLeftButtonDownEvent))

Note that this will cause the system and other applications to think the mouse was actually clicked. If you just want to initiate a WPF event, try RaiseEvent( new RoutedEventArgs( UIElement.MouseLeftButtonDownEvent ) ).

这篇关于射击MouseLeftButtonDown事件编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆