How do I test SendInput in c#
- by JoelHess
How can I tell if my call to SendInput is working properly? I have a small snippet below, and the message never seems to get hit. SendInput() returns 1, and there's no errors, so I assume that the message is going out properly.
I've also tried the Form KeyPress and KeyDown Events, and I never seem to get those either.
private void button1_Click(object sender, EventArgs e)
{
INPUT input = new INPUT();
input.mkhi.ki.wVk = (byte)System.Windows.Forms.Keys.B;
uint result = SendInput(1, ref input, Marshal.SizeOf(new INPUT()));
}
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_KEYDOWN)
{
Console.WriteLine("GotIt");
}
base.WndProc(ref m);
}