public static void main(String[] args) {
    // get the taskbar's window handle
    HWND shellTrayHwnd = User32.instance.FindWindow(User32.SHELL_TRAY_WND, null);

    // use it to minimize all windows
    User32.instance.SendMessageA(shellTrayHwnd, User32.WM_COMMAND, User32.MIN_ALL, 0);

    // Test
    // System.out.println(shellTrayHwnd);
    // System.out.println(User32.WM_COMMAND);

    // sleep for 3 seconds
    try {
      Thread.sleep(3000);
    } catch (InterruptedException e) {
    }

    // then restore previously minimized windows
    User32.instance.SendMessageA(shellTrayHwnd, User32.WM_COMMAND, User32.MIN_ALL_UNDO, 0);
    byte[] windowText = new byte[512];
    PointerType hwnd = User32.INSTANCE.GetForegroundWindow();
    // then you can call it!
    User32.INSTANCE.GetWindowTextA(hwnd, windowText, 512);
    System.out.println(Native.toString(windowText));
    // System.out.println(User32.INSTANCE.GetForegroundWindow());

  }
Exemplo n.º 2
0
 public static final HWND createWindowEx(
     final int exStyle,
     final String className,
     final String windowName,
     final int style,
     final int x,
     final int y,
     final int width,
     final int height,
     final HWND parent,
     final HMENU menu,
     final HINSTANCE instance,
     final LPVOID param) {
   final HWND hWnd =
       User32.INSTANCE.CreateWindowEx(
           exStyle,
           new WString(className),
           windowName,
           style,
           x,
           y,
           width,
           height,
           parent,
           menu,
           instance,
           param);
   if (hWnd == null) throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
   return hWnd;
 }
  static void setOverlayIcon(IdeFrame frame, Object icon, boolean dispose) {
    if (!isEnabled()) {
      return;
    }

    if (icon == null) {
      icon = Pointer.NULL;
    }
    mySetOverlayIcon.invokeInt(
        new Object[] {myInterfacePointer, getHandle(frame), icon, Pointer.NULL});
    if (dispose) {
      User32.INSTANCE.DestroyIcon((WinDef.HICON) icon);
    }
  }
Exemplo n.º 4
0
 public static final void destroyWindow(final HWND hWnd) {
   if (!User32.INSTANCE.DestroyWindow(hWnd))
     throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
 }
Exemplo n.º 5
0
 public static final int registerWindowMessage(final String lpString) {
   final int messageId = User32.INSTANCE.RegisterWindowMessage(lpString);
   if (messageId == 0) throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
   return messageId;
 }