用JAVA打开指定应用程序(软件),比如qq,浏览器。代码如下
public static void open(){if (java.awt.Desktop.isDesktopSupported()) {try { java.awt.Desktop dp = java.awt.Desktop.getDesktop();if (dp.isSupported(java.awt.Desktop.Action.BROWSE)) {dp.open(new File("D:\\Program Files\\QQ.exe"));//把应用程序的地址传进来即中打开 }} catch (java.lang.NullPointerException e) {} catch (java.io.IOException e) {}}}
截屏代码
public static void captureScreen(String fileName) throws Exception {System.out.println("run");Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();Rectangle screenRectangle = new Rectangle(screenSize);Robot robot = new Robot();BufferedImage image = robot.createScreenCapture(screenRectangle);// robot.ImageIO.write(image, "png", new File(fileName));}