tags:

views:

61

answers:

2

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 object.

any thoughts would be great

+1  A: 

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

Jean-Bernard Pellerin
well if I could a handle I could get coords. If I know an element name say a button. buttonxyz in Java how would I get a handle to it. Do I need to use system32 calls
ducati1212
From what I've done system32 is the easiest. But then again I haven't spent much time in this domain, I was just giving a direction you could investigate.
Jean-Bernard Pellerin
A: 

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.

trashgod