Faking A Keyboard or Mouse Event

时间:2015-07-28 17:15:05

标签: c# winforms events .net-4.5

I've been trying to figure out how to fake, not simulate, keyboard and mouse input. By this I mean the system goes through the process as if the actual event occurred, such as a mouse click, but does not actually perform the event, such as clicking the mouse.

Or if you wanted to make the system think your mouse had moved even though it did not. Sort of a "virtual" move that doesn't actually happen/effect the mouse.

Is it possible to override the simulated mouse clicks and events to make them not actually click while the system thinks they have?

2 个答案:

答案 0 :(得分:1)

这是一个包装键盘和鼠标的好项目。这是mouse input simulator文件供参考。要查看较低级别的工作,请导航到该项目中的WindowsInput.Native命名空间。

答案 1 :(得分:0)

感谢各位帮忙。我终于能够通过lrb的答案实现我想要的目标。

我使用该库来伪造输入,并且在我试图制作鼠标摇摆器的宏观方案中但是在用户使用鼠标时应用程序运行的情况下实际上不影响用户的鼠标。这就是为什么我想“伪造”鼠标而不是移动实际的鼠标。再次感谢所有这一切都很棒。

Icemanind我仍然对订阅活动而不是拥有事件处理程序的想法感到好奇。这样可以让我在没有实际点击正确的情况下诱导点击鼠标之类的东西吗?