我有一個場景,我需要將點擊事件發送到一個獨立的應用程序。我用下面的代碼啓動了該應用程序。發送點擊消息到另一個應用程序進程
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