示例#1
0
  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();
  }
示例#2
0
 public boolean restoreWindow(HWND handle) {
   return user32.ShowWindow(handle, WinUser.SW_RESTORE);
 }
示例#3
0
 public boolean minimizeWindow(HWND handle) {
   return user32.ShowWindow(handle, WinUser.SW_MINIMIZE);
 }
示例#4
0
 public boolean showWindow(HWND handle) {
   return user32.ShowWindow(handle, WinUser.SW_SHOW);
 }
示例#5
0
 public boolean activateWindow(HWND handle) {
   boolean result = user32.SetForegroundWindow(handle);
   return result;
 }
示例#6
0
 public HWND findWindowByTitle(String title) {
   HWND handle = user32.FindWindow(null, title);
   return handle;
 }