开发者

java get screen coordinates for any object

I am trying to use java to get screen coordinates for any object in the DOM.

For example I want to write code to take a button name ()or any object in a web or windows app) and return x, y coords so I can perform mouse actions on that button using java robot.

I dont want to get coords myself because I want it more dynamic so get current coords on the fly pass to robot and interact with ob开发者_如何学运维ject.

any thoughts would be great


If you want it to be dynamic, get an object handle instead of a location. Then you can call operations on the object directly.


You can traverse the Container hierarchy using getComponentCount() and getComponent(), invoking getBounds() as required. The Robot Framework project may be of interest, too. For reference, the article Painting in AWT and Swing uses the term containment hierarchy, rather than document object model.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜