[英]How to check mouse click position is on required application?
I know the mouse click position using API GetCursorPos
and the handle of application ( HWND
). 我知道使用API
GetCursorPos
和应用程序HWND
( HWND
)的鼠标单击位置。
How can I check mouse click position is on this application? 如何检查此应用程序上的鼠标单击位置?
My view: 我的观点:
GetWindowRect(hWnd, &rect);
) GetWindowRect(hWnd, &rect);
) PtInRect(&rect, p)
) PtInRect(&rect, p)
) This is not working if windows are overlapping. 如果窗口重叠,则无法使用。
As we know the handle of targeted screen handle and click cursor position: 我们知道目标屏幕的句柄和单击光标位置:
// 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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.