Faking Mouse/Keyboard Input

Started by
2 comments, last by ploogle 16 years, 2 months ago
I was wondering how I would go about faking keyboard and mouse input in c#. For example, a program that makes the computer (and all programs requiring mouse input) think that the mouse is moving in a particular direction. Also, basically the opposite of a keylogger: a program that makes the computer (and, again, all programs requiring keyboard input) think that certain keys are being pressed. I appreciate any help you guys can give me.
Advertisement
keybd_event, mouse_event

Apparently those are depreciated, replaced by: SendInput
Thanks! Can this be used in C#? My program needs to be coded in C#, since it needs to use a specific third party library only available in C#.
http://pinvoke.net/default.aspx/user32/SendInput.html
Here is some code I found that might help, and I'd like to clarify some things:

1. I'm assuming that this part of the program actually sends the input to windows?
    // Key down the actual key-code    structInput.ki.wVk = vk;    intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));


2. What headers would I need to put in the program to use Win32 and SendInput?

[Edited by - ploogle on February 9, 2008 5:33:45 PM]

This topic is closed to new replies.

Advertisement