我想在后台窗口中使用键盘和鼠标(窗口是 dx 窗口)。
HWND myhwnd = GetForegroundWindow();
PostMessage(myhwnd, WM_KEYDOWN, 0x33, 0); //press "3"
PostMessage(myhwnd, WM_KEYUP, 0x33, 0);
LPARAM lParam = MAKELPARAM(300,100);
PostMessage(myhwnd, WM_MOUSEMOVE, 0,lParam); // mouse move
PostMessage(myhwnd, WM_RBUTTONDOWN, 0,lParam); // mouse click
PostMessage(myhwnd, WM_RBUTTONUP, 0, lParam);
按“3”,鼠标点击成功。但我移动鼠标失败。