3

I want to get all the child handles of the parent window. This can be well done in AutoIt script but, we want this in java and this command is unavailable in AutoItX4Java.jar. I started to create it, and took example of calculator:

public static HWND GetWindow( WinDef.HWND hWnd, WinDef.DWORD uCmd)  {
    User32 user32 = (User32) Native.loadLibrary("user32", User32.class);
    return user32.GetWindow(hWnd, uCmd);
}

public static void main(String[] args) {
    WinDef.HWND hWnd = User32.INSTANCE.FindWindow("CalcFrame", "Calculator");
    WinDef.DWORD a = new WinDef.DWORD(5);   // child 5
    System.out.println("parent : " + hWnd);
    WinDef.HWND hWnd3 = GetWindow ( hWnd , a );
    System.out.println("child " + hWnd3);
    WinDef.DWORD b = new WinDef.DWORD(2);  // next 2
    WinDef.HWND hWnd2= GetWindow ( hWnd3 , b );
    System.out.println(hWnd2);
    int x = 0;
    while (hWnd2  != null ) {
        x++;
        System.out.println(hWnd2);
        hWnd2= GetWindow ( hWnd , b );
        if (x>30)
            break;
    }
}

This code is not working and throwing some errors.

output:

parent : native@0x180d78

child native@0x4400f8

null

Does not find the sibling controls.

Community
  • 1
  • 1
Umesh
  • 121
  • 6

0 Answers0