geraldlim
geraldlim

Reputation: 31

WINAPI cursor click position on application window

I need to write a small program that can know where the user click the button or somehow on a application windows whatever the application windows change the size .

Through use the windows API, now I can only get the global cursor click position.

I find a small program from china that have similar function using AHK to implement it. Maybe the author use this (WinGetPos) see the image below:

enter image description here

So, Is the any windows api or other QT5, C++ function can help me get the application windows cursor click position. (I develop in QT5)

post some code on here:

GetCursorPos (&screenpoint);
hwndFoundWindow = WindowFromPoint (screenpoint);
mp.DisplayInfoOnFoundWindow(QString::fromLocal8Bit("L"), hwndFoundWindow, pMouseStruct->pt.x, pMouseStruct->pt.y);

Upvotes: 0

Views: 1241

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308206

The ScreenToClient function in the Windows API can be used to convert from screen coordinates to window (client area) coordinates. You will need to know the HWND of your application window.

Upvotes: 1

Related Questions