Tag: sendmessage postmessage

使用post / sendmessage做鼠标点击不起作用

可能重复: 如何在C#中模拟鼠标点击? 我试过了 Window = FindWindow(null, “untitled – Paint”); PostMessage(WindowToFind, WM_MOUSEMOVE, 0, location); PostMessage(WindowToFind, WM_LBUTTONDOWN, ((int)Keys.LButton), location); 位置是100 * 0x10000 + 100 100×100等。我怀疑它是错的。 我尝试用0交换((int)Keys.LButton) ,没有用。 我尝试在lbuttondown和thread.sleep之间lbuttondown lbuttonup (以及postmessage应该等待没有thread.sleep但是等等)我使用0x0200进行mousemove和0x0202进行左键按钮。 不知道为什么它根本不起作用。

我无法理解如何使用SendMessage或PostMessage调用

我需要在第三方应用程序中模拟按键。 假设我有一个需要向Calculator应用程序发送“8”的C#应用​​程序。 我不能使用.Net的SendKeys或win32 api的keybd_event,因为它们都要求窗口是最活跃的窗口,这在我的情况下不是这种情况。 这样我就可以调用sendMessage和postMessage。 我在过去的三个小时里一直试图获得一些结果,但现在我完全没有希望了。 我有以下内容: [DllImport(“user32.dll”)] public static extern int FindWindow(string lpClassName,string lpWindowName); [DllImport(“user32.dll”)] public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam); [return: MarshalAs(UnmanagedType.Bool)] [DllImport(“user32.dll”, SetLastError = true)] public static extern bool PostMessage(int hWnd, uint Msg, int wParam, int lParam); private void button1_Click(object sender, EventArgs e) { const int […]