I'm trying to list and get the content of Edit Controls from an external Window in C++ / Java, unfortunately with no success.
When I call GetWindowText or GetWindowTextA it returns an empty value on Edit Controls, I know there are some differences between GetWindowText / GetWindowTextW and GetWindowTextA but I don't know What I'm doing wrong since it works on all other controls.
Here the C++ Code:
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
cout <<"----------CHILD------------"<<endl;
char class_name[80];
char title[80];
GetClassName(hwnd,class_name, sizeof(class_name));
GetWindowText(hwnd,title,sizeof(title));
cout <<"\tWindow title: "<<title<<endl;
cout <<"\tClass name: "<<class_name<<endl<<endl;
return TRUE;
}
Java Code:
User32.INSTANCE.EnumChildWindows(hWnd, new User32.WNDENUMPROC() {
@Override
public boolean callback(Pointer hWnd, Pointer arg) {
byte[] windowClassx = new byte[512];
User32.INSTANCE.GetClassNameA(hWnd, windowClassx, 512);
String wClass = Native.toString(windowClassx);
System.out.println(" - Found sub window / control class: " + new String(windowClassx).trim());
if (wClass.toLowerCase().equals("edit")){
byte[] windowTextx = new byte[128];
user32.GetWindowText(hWnd, windowTextx, 128);
String wText = Native.toString(windowTextx);
System.out.println(wText);
}
return true;
}
}, null);
I'm not sure what is causing your problem, but this has worked just fine for me:
Edit
You should get the edit text a different way, via
e.g.,