Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jna getDesktop bringWindowToTop
- SetForegroundWindow
- SwitchToThisWindow
- ShowWindow
- BringWindowToTop
- import com.sun.jna.Native;
- import com.sun.jna.platform.win32.WinDef.HWND;
- import com.sun.jna.win32.W32APIOptions;
- public class ToggleDesktop3 {
- public interface User32 extends W32APIOptions {
- public static final String SHELL_TRAY_WND = "Shell_TrayWnd";
- public static final int WM_COMMAND = 0x111;
- public static final int MIN_ALL = 0x1a3;
- public static final int MIN_ALL_UNDO = 0x1a0;
- User32 instance = (User32) Native.loadLibrary("user32", User32.class,
- DEFAULT_OPTIONS);
- HWND FindWindow(String winClass, String title);
- long SendMessageA(HWND hWnd, int msg, int num1, int num2);
- }
- 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);
- // 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);
- }
- }
Add Comment
Please, Sign In to add comment