• 鼠标


    一、代码如下

    package www.woniu.auto;
    
    import java.awt.AWTException;
    import java.awt.Robot;
    import java.awt.event.InputEvent;
    import java.awt.event.KeyEvent;
    import java.io.IOException;
    
    public class RobotMouse {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		try {
    			//启动计算器
    			Runtime.getRuntime().exec("calc.exe");
    			Thread.sleep(3000);
    			
    			//鼠标操作
    			Robot robot= new Robot();
    			robot.mousePress(InputEvent.BUTTON1_MASK);
    			robot.mouseRelease(InputEvent.BUTTON1_MASK);
    			Thread.sleep(20000);
    			
    			robot.mousePress(InputEvent.BUTTON3_MASK);
    			robot.mouseRelease(InputEvent.BUTTON3_MASK);
    			Thread.sleep(20000);
    			
    			//程序退出
    			robot.keyPress(KeyEvent.VK_ALT);
    			robot.keyPress(KeyEvent.VK_F4);
    			robot.keyRelease(KeyEvent.VK_ALT);
    			robot.keyRelease(KeyEvent.VK_F4);
    			
    			
    		} catch (AWTException e) {
    			// TODO Auto-generated catch block  
    			e.printStackTrace();
    		} catch (InterruptedException e) {
    			// TODO Auto-generated catch block  InterruptedException  IOException
    			e.printStackTrace();
    		} catch (IOException e) {
    			// TODO Auto-generated catch block  InterruptedException  IOException
    			e.printStackTrace();
    		}
    
    	}
    
    
    }
    
  • 相关阅读:
    探讨GTK+应用程序的优化方法
    X Window研究笔记(9)
    X Window研究笔记(10)
    X Window研究笔记(7)
    用gdbserver调试共享库(改进版)
    X Window研究笔记(11)
    Gtkminimo中的几个BUG
    编译基于DirectFB的Phoneme(Advance)
    X Window研究笔记(8)
    X Window研究笔记(12)
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7465702.html
Copyright © 2020-2023  润新知