Maciek
Maciek

Reputation: 19893

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

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 ?

Upvotes: 1

Views: 2190

Answers (3)

Ivo
Ivo

Reputation: 416

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.

Upvotes: 1

CriGoT
CriGoT

Reputation: 1014

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)

Upvotes: 1

Michael
Michael

Reputation: 9058

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

Upvotes: 4

Related Questions