Guest User

Untitled

a guest
Aug 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. jna getDesktop bringWindowToTop
  2. SetForegroundWindow
  3. SwitchToThisWindow
  4. ShowWindow
  5. BringWindowToTop
  6.  
  7. import com.sun.jna.Native;
  8. import com.sun.jna.platform.win32.WinDef.HWND;
  9. import com.sun.jna.win32.W32APIOptions;
  10.  
  11. public class ToggleDesktop3 {
  12. public interface User32 extends W32APIOptions {
  13. public static final String SHELL_TRAY_WND = "Shell_TrayWnd";
  14. public static final int WM_COMMAND = 0x111;
  15. public static final int MIN_ALL = 0x1a3;
  16. public static final int MIN_ALL_UNDO = 0x1a0;
  17.  
  18. User32 instance = (User32) Native.loadLibrary("user32", User32.class,
  19. DEFAULT_OPTIONS);
  20.  
  21. HWND FindWindow(String winClass, String title);
  22.  
  23. long SendMessageA(HWND hWnd, int msg, int num1, int num2);
  24. }
  25.  
  26. public static void main(String[] args) {
  27. // get the taskbar's window handle
  28. HWND shellTrayHwnd = User32.instance.FindWindow(User32.SHELL_TRAY_WND,
  29. null);
  30.  
  31. // use it to minimize all windows
  32. User32.instance.SendMessageA(shellTrayHwnd, User32.WM_COMMAND,
  33. User32.MIN_ALL, 0);
  34.  
  35. // sleep for 3 seconds
  36. try {
  37. Thread.sleep(3000);
  38. } catch (InterruptedException e) {
  39. }
  40.  
  41. // then restore previously minimized windows
  42. User32.instance.SendMessageA(shellTrayHwnd, User32.WM_COMMAND,
  43. User32.MIN_ALL_UNDO, 0);
  44. }
  45. }
Add Comment
Please, Sign In to add comment