Find item position on screen

I need a function to retrieve the size of an element, whether it is an Apple Applet window in a browser, text fields in programs, an application window, etc.

Now I do not know what this function is called, but I downloaded an example from an application that has this functionality.

Example (red box)

What I need in order to be able to get its size and its coordinates on the screen with this. It should be in C ++.

Therefore, if someone could give an example, or at least the name of this function, I would be grateful.

Edit 1: - The Qt tag has been removed, since it actually has nothing to do with it.

I found a program that has the function I'm looking for: it is called Scar Divi, which is a scripting tool for performing repetitive actions, mainly used to cheat in a game called Runescape. Unfortunately, this is a closed source.

+3
source share
3 answers

I have found a solution!

POINT p;
HWND wnd;
RECT rec;

GetCursorPos(&p);
wnd = WindowFromPoint(p);
GetWindowRect(wnd, &rec);

This will give you the coordinates for the field (extract from rec).

0
source

Are you looking for Window Geometry or a desktop widget

+1
source

After receiving the screen image (for this, Qt will have something similar)

You need an image processing library, such as openCV , to find the rectangle - find "Convert Hough"

0
source

Source: https://habr.com/ru/post/1782523/


All Articles