我有一个场景,我需要将点击事件发送到一个独立的应用程序。我用下面的代码启动了该应用程序。发送点击消息到另一个应用程序进程
private Process app;
app = new Process();
app.StartInfo.FileName = app_path;
app.StartInfo.WorkingDirectory = dir_path;
app.Start();
现在我想发送鼠标单击消息到该应用程序,我有相对于应用程序窗口的具体坐标。我如何使用Windows Messaging或任何其他技术来做到这一点。
我用
[DllImport("user32.dll")]
private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);
它运作良好,但会使指针移动为好。所以不适合我的需要。
然后我用。
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
它适用于最小化最大化,但不适用于鼠标事件。
我使用mousevents的代码是,
WM_LBUTTONDOWN = 0x201, //Left mousebutton down
WM_LBUTTONUP = 0x202, //Left mousebutton up
WM_LBUTTONDBLCLK = 0x203, //Left mousebutton doubleclick
WM_RBUTTONDOWN = 0x204, //Right mousebutton down
WM_RBUTTONUP = 0x205, //Right mousebutton up
WM_RBUTTONDBLCLK = 0x206, //Right mousebutton do
感谢提前的帮助,并等待反馈。
停止发送输入消息,他们应该发布。无论如何,使用`SendInput()`可能会更好,这是虚假输入的正确方法。 – 2011-03-04 11:18:29