Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimize all applications

Tags:

java

I'm trying to minimize all open applications, and using the following code:

public class Test {
    public static void main(String args[]) throws Exception{
        Runtime.getRuntime().exec
        (new String[] {
        "cmd.exe", 
        "/c",
        "\"" + System.getenv("APPDATA") + 
        "\\Microsoft\\Internet Explorer\\Quick Launch\\Show Desktop.scf" + "\""
        });
    }
}

When I run the code, nothing happens.

I'm using Windows 7, when I open Internet Explorer the PC crash from some virus reason (maybe there is a connection?)

like image 904
Presen Avatar asked Dec 12 '25 03:12

Presen


1 Answers

Here is a way to show the desktop, using the Java's Robot class.
This class simulates mouse and keyboard inputs.

    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_WINDOWS);
    robot.keyPress(KeyEvent.VK_D);
    robot.keyRelease(KeyEvent.VK_D);
    robot.keyRelease(KeyEvent.VK_WINDOWS);
like image 94
Presen Avatar answered Dec 13 '25 16:12

Presen