Is there any way to read data from a program which is developed using SWING. I am able to read Title of the window using Native JNA. I have tried the below code and it is giving me the title of window.
public class JNATest {
HWND window = null;
public static void main(String[] args) {
JNATest jna = new JNATest();
if(jna.isWindowOpen("Test")){
jna.activateWindow();
}
}
public void activateWindow() {
if(window != null) {
User32.INSTANCE.ShowWindow(window, 9);
User32.INSTANCE.SetForegroundWindow(window);
}
}
public boolean isWindowOpen(String title) {
window = null;
User32.INSTANCE.EnumWindows(new WNDENUMPROC() {
@Override
public boolean callback(HWND hWnd, Pointer arg1) {
if(window == null) {
char[] windowText = new char[512];
User32.INSTANCE.GetWindowText(hWnd, windowText, 512);
String wText = Native.toString(windowText);
if (wText.contains(title)) {
window = hWnd;
}
System.out.println(" - Found sub window / control class: " + new String(windowText).trim());
}
return true;
}
}, null);
return window != null;
}