Java - Inspector de Objectos en Java

 
Vista:

Inspector de Objectos en Java

Publicado por JC (1 intervención) el 13/02/2009 09:21:17
Hola a todos,

Estamos intentando hacer un inspector de objectos en java para luego
utilizar sus propiedades a la hora de automatizar pruebas.
Hemos conseguido reconocer los objetos que se cargan en Internet Explorer.
También reconocemos las ventanas y algunas de sus propiedades.
Pero no somos capaces de reconocer por ejemplo botones, checkbox... de
cualquier aplicación: Word, WSAD, Excel...
Entiendo que son objetos OLE pero no se como recuperar su información
teniendo como único valor el Handle de la ventana que lo contiene y la
posición del ratón.
Os adjunto mas abajo parte del código que nos permite reconocer los
objetos html en IE.
Si alguien nos puede dar una pista estaríamos muy agradecidos.

Un saludo a todo el grupo.

Código:
...
public static void getChildObject(Wnd hWnd, int x, int y){
ComFunctions.coInitialize();

UInt SMTO_ABORTIFHUNG = new UInt(2);

Int lResult = new Int(0);
Pointer lresPointer = new Pointer(lResult);

UInt nMsg = new UInt(0);

User32.getInstance().getFunction("RegisterWindowMessageA").invoke(nMsg, new
AnsiString("WM_HTML_GETOBJECT"));

Parameter[] params = new Parameter[] { hWnd, nMsg,
new UInt(0), new UInt(0), SMTO_ABORTIFHUNG,
new UInt(100), lresPointer };

User32.getInstance().getFunction("SendMessageTimeoutA").invoke(null,params);

IUnknownImpl object = new IUnknownImpl();

HResult retVal = new HResult();
iid = new IID();

Function.call("oleacc", "ObjectFromLresult", retVal,
lResult, new Pointer(iid),
new UInt(0), new Pointer(object));

ComException.checkResult(retVal);

IHTMLDocument2Impl iHTMLDocument2Impl = new IHTMLDocument2Impl(object);

int xx = (int) (x-hWnd.getBounds().getLeft());
int yy = (int) (y-hWnd.getBounds().getTop());

IHTMLElement iHTMLElement = iHTMLDocument2Impl.elementFromPoint(new
Int32(xx), new Int32(yy));
System.out.println(iHTMLElement.getTagName());

try {
System.out.println(" "+iHTMLElement.getAttribute(new BStr("TYPE"),
new Int32(0)).getValue());
System.out.println(" "+iHTMLElement.getAttribute(new
BStr("NAME"), new Int32(0)).getValue());
System.out.println(" "+iHTMLElement.getAttribute(new
BStr("VALUE"), new Int32(0)).getValue());
} catch (Exception e) {
// TODO: handle exception
}
}
...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder