开发者

Function to retrieve the size of an element

What I need is a function to retrieve the size of an element, be it a Java Applet window in a browser, text boxes in programs, applications window and so on.

Now I don't know what this kind of function is called, but I uploaded an example from an application that had that functionality.

<a href="http://img408.imageshack.us/img408/9638/placementbox.png">Example (The red box)</a>

开发者_运维知识库What I need to be able to with this is get its size and its coordinates on the screen. This needs to be in C++.

So ff anyone could give an example, or atleast the name of that kind of function, I would be grateful.

I found a program that has the function I seek: It is called Scar Divi, which is a scriptable tool to perform repetitive actions, mostly uses for cheating in a game called Runescape it seems. Unfortunately it is closed source.


Are you looking for Window Geometry or desktop widget?


After getting an image of the screen (there will be somethign in Qt to do this)

You need an image processing library like openCV to find the rectangle - look for "Hough Transform"


I found the solution!

POINT p;
HWND wnd;
RECT rec;

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜