在没有实际使用鼠标的情况下模拟鼠标在WPF控件上的输入/移动/离开 [英] Simulate mouse Enter/Move/Leave on WPF control without real mouse usage

查看:136
本文介绍了在没有实际使用鼠标的情况下模拟鼠标在WPF控件上的输入/移动/离开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在WPF控件上模拟鼠标Enter/Move/Leave,而无需实际使用鼠标.我正在尝试使用以下代码进行操作:

Hi

I need to simulate mouse Enter/Move/Leave on WPF control without real mouse usage. I'm trying to do it using this code:

MouseEventArgs mouse1 = new MouseEventArgs(Mouse.PrimaryDevice, 0) {RoutedEvent = Mouse.MouseEnterEvent};
MyControl.RaiseEvent(mouse1);

MouseEventArgs mouse2 = new MouseEventArgs(Mouse.PrimaryDevice, 0) { RoutedEvent = Mouse.MouseMoveEvent };
MyControl.RaiseEvent(mouse2);

MouseEventArgs mouse3 = new MouseEventArgs(Mouse.PrimaryDevice, 0) { RoutedEvent = Mouse.MouseLeaveEvent };
MyControl.RaiseEvent(mouse3);

但是,如何为鼠标移动指定鼠标坐标呢?没有RaiseEvent,我可以使用任何其他方式,只是不能使用真正的鼠标来完成此任务.

But how I can specify mouse coordinates for mouse move? I can use any other way, without RaiseEvent, I just can't use real mouse for this task.

推荐答案

只是好奇您的情况是什么?这是用于测试方案吗?

WPF测试团队已发布此TestAPI- http://www.codeplex.com/TestApi

它包含用于发送低级鼠标和键盘命令以模拟用户输入的方法.

希望这会有所帮助.
Just curious what you're scenario?  Is this for a testing scenario? 

The WPF Test team has released this TestAPI - http://www.codeplex.com/TestApi

It contains methods for sending low level mouse and keyboard commands to simulate user input.

Hope this helps.


这篇关于在没有实际使用鼠标的情况下模拟鼠标在WPF控件上的输入/移动/离开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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