开发者

How do I send mouse and keyboard events to another process?

开发者 https://www.devze.com 2022-12-09 18:56 出处:网络
Let\'s assume that we\'ve got 2 windows processes , Process A is the sender, and Process B is the receiver.

Let's assume that we've got 2 windows processes ,

Process A is the sender, and Process B is the receiver.

开发者_如何转开发

Process B is running a classic Win32 API events loop

How do I generate and send mouse and keyboard events from process A to B ?


Basically via SendMessage or PostMessage. If you want to simulate input events for the whole operating system, then SendInput might be interesting.


You may want to check TestAPI in Codeplex it includes some C# classes that wrap SendMessage and PostMessage APIs (http://testapi.codeplex.com/SourceControl/changeset/view/35517#424245)


TestApi actually wraps up SendInput internally, and exposes a couple of simple classes -- Mouse and Keyboard -- to help you simulate input. SendInput provides the most general way to inject input, but is a notoriously tricky API to use -- the wrappers simplify the usage greatly.

See Link for specific usage examples.

0

精彩评论

暂无评论...
验证码 换一张
取 消