How do I test SendInput in c#
Posted
by JoelHess
on Stack Overflow
See other posts from Stack Overflow
or by JoelHess
Published on 2010-03-18T14:27:50Z
Indexed on
2010/03/18
14:31 UTC
Read the original article
Hit count: 487
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);
}
© Stack Overflow or respective owner