1
如何判斷我的SendInput調用是否正常工作?我在下面有一小段代碼,並且這個消息似乎從未被打過。 SendInput()返回1,並且沒有錯誤,所以我假設該消息正常發佈。如何在c#中測試SendInput
我也試過了Form KeyPress和KeyDown Events,而且我從來沒有看到過這些。
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);
}