代码之家  ›  专栏  ›  技术社区  ›  Swapnil

如何检查所需应用程序上的鼠标点击位置?

  •  0
  • Swapnil  · 技术社区  · 8 年前

    GetCursorPos 以及应用程序的处理( HWND ).

    如何检查此应用程序上的鼠标单击位置?

    我的观点:

    • 从其句柄获取应用程序的边界框。( GetWindowRect(hWnd, &rect); )
    • 选中光标位置位于该边界框中。( PtInRect(&rect, p) )

    如果窗口重叠,则此操作无效。

    1 回复  |  直到 8 年前
        1
  •  0
  •   Swapnil    8 年前

    正如我们所知,目标屏幕手柄和点击光标位置的手柄:

    // 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 
    }