代码
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
public Window SendKey(int key)
{
SendKey(Message.WM_KEYDOWN, new IntPtr((Int32)key), new IntPtr(0))
.SendKey(Message.WM_KEYUP, new IntPtr((Int32)key), new IntPtr(0));
return this;
}
private Window SendKey(uint Msg, IntPtr wParam, IntPtr lParam)
{
SendMessage(_windowHandler, Msg, wParam, lParam);
Thread.Sleep(50);
return this;
}
var wind = new Window(new IntPtr(0x000601f2));
wind.SendKey(Keys.VK_F5);
结果
有人对这个问题有任何想法吗?