public String GetWindowInfoXml() { final List<WindowInfo> infoList = new ArrayList<WindowInfo>(); class ChildWindowCallback implements WinUser.WNDENUMPROC { public boolean callback(HWND hWnd, Pointer lParam) { infoList.add(new WindowInfo(hWnd, true)); return true; } } class ParentWindowCallback implements WinUser.WNDENUMPROC { public boolean callback(HWND hWnd, Pointer lParam) { infoList.add(new WindowInfo(hWnd, false)); user32.EnumChildWindows(hWnd, new ChildWindowCallback(), new Pointer(0)); return true; } } user32.EnumWindows(new ParentWindowCallback(), 0); // convert list to string xml StringBuilder sb = new StringBuilder(""); for (WindowInfo w : infoList) { // System.out.println(w); sb.append(w + "\r\n"); } sb.append("count - " + infoList.size() + "\r\n"); return sb.toString(); }
public boolean restoreWindow(HWND handle) { return user32.ShowWindow(handle, WinUser.SW_RESTORE); }
public boolean minimizeWindow(HWND handle) { return user32.ShowWindow(handle, WinUser.SW_MINIMIZE); }
public boolean showWindow(HWND handle) { return user32.ShowWindow(handle, WinUser.SW_SHOW); }
public boolean activateWindow(HWND handle) { boolean result = user32.SetForegroundWindow(handle); return result; }
public HWND findWindowByTitle(String title) { HWND handle = user32.FindWindow(null, title); return handle; }