Using the SendInput API call from C#

L

Logan McKinley

need my C# app to send a character to a different application. I believe I
need to use the SendInput API call and to pass a KEYBDINPUT struct into
that but I am lost past that point. Here is the code I have

struct KEYBDINPUT
{
public short wVk; //the actual key
public short wScan; //not needed
public int dwFlags; //not needed
public int time; //not needed
public IntPtr dwExtraInfo; //not needed
}
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
private static extern UINT SendInput(
UINT nInputs, // count of input events
LPINPUT pInputs, // array of input events
int cbSize // size of structure
);

I was hoping someone might help fill in the gaps in my understanding. How
would i send the char 'c' for instance.

Thanks in advance,
~Logan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top