CGP
CGP

Reputation: 303

How to simulate mouse and keyboard to operate an application from a WinForm program?

I am writing a WinForm program in C#, to move mouse cursor, click mouse, stroke keyboard, to operate another running GUI application in Windows. Is this possible, how to do it? I mean the simulation of mouse and keyboard and operation of another GUI application.

Thanks a lot!

Upvotes: 0

Views: 335

Answers (1)

Eric Brown
Eric Brown

Reputation: 13932

SendInput is your friend here. It doesn't have a direct C# wrapper, but it's easy to use with P/Invoke.

SendInput places input into the input queue, which then gets dispatched normally, so you will need to set focus to the target application first.

Upvotes: 1

Related Questions