Capture and send keyboard / mouse input in C#

限于喜欢 提交于 2019-11-29 02:35:46

AFAIK, there's no way to capture the GLOBAL keyboard & mouse events. But there are a few articles on CodeProject which demonstrate the creation of .NET class wrappers for the same.

You can check them out here:

1) Processing Global Mouse and Keyboard Hooks in C#

2) Global Mouse and Keyboard Library

EDIT: BTW, I had created a SMALL keylogger in C# using the 1st library :)

Some months ago, I used C# to create an app that read from a wii nunchuck and move the mouse. My first option was to use the cursor Class to move the mouse like this

Cursor.Position = new Point(Cursor.Position.X + 10, Cursor.Position.Y + 10);

All was fine, but did't work when playing games because they manage the mouse in a different way, so at the end I used the Global Hooks that Kirtan mentioned here (+1). Based in my experience, I recomend you to use Global Hooks.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!