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 Wnd开发者_JAVA技巧Proc(ref Message m)
{
if (m.Msg == WM_KEYDOWN)
{
Console.WriteLine("GotIt");
}
base.WndProc(ref m);
}
It turns out since I was looking the down key, I needed to listen to ProcCmdKeys, and not just the key down event.
精彩评论