我知道使用API GetCursorPos
和应用程序句柄(HWND
)的鼠标单击位置。
如何检查此应用程序上的鼠标点击位置?
我的看法:
GetWindowRect(hWnd, &rect);
)PtInRect(&rect, p)
)如果窗口重叠,这不起作用。
我们知道目标屏幕句柄的手柄和点击光标位置:
// hWnd : Already known windows handle
GetCursorPos(&p);
HWND hWndFromPoint = WindowFromPoint(p);
// If the handle got from click point is child of the desire window means it is clicked on the desire window itself.
if (IsChild(hWnd, hWndFromPoint))
{
// Do something on Mouse click
}