Using the SendInput API call from C#

  • Thread starter Thread starter Logan McKinley
  • Start date Start date
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
 
Back
Top