!7 lib 1400155 lib 1400156 // jna 5.1 import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinDef.RECT; import com.sun.jna.platform.win32.WinUser; import com.sun.jna.platform.win32.WinUser.WNDENUMPROC; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.platform.win32.User32; /*public interface User32 extends StdCallLibrary { User32 INSTANCE = cast Native.loadLibrary("user32", User32.class); boolean EnumWindows(WinUser.WNDENUMPROC lpEnumFunc, Pointer arg); int GetWindowTextA(HWND hWnd, byte[] lpString, int nMaxCount); bool GetWindowRect(HWND hWnd, LPRECT lpRect); }*/ p { User32.INSTANCE.EnumWindows(new WNDENUMPROC { int count = 0; @Override public boolean callback(HWND hWnd, Pointer arg1) { char[] windowText = new[512]; User32.INSTANCE.GetWindowText(hWnd, windowText, windowText.length); new RECT rect; User32.INSTANCE.GetWindowRect(hWnd, rect); S wText = Native.toString(windowText); // get rid of this if block if you want all windows regardless of whether // or not they have text if (wText.isEmpty()) { return true; } print("Found window with text " + hWnd + ", total " + ++count + " Text: " + wText + ", rect: " + rect); return true; } }, null); }