import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
public class Monitor {
/**
* 模拟按键
*
* @throws Exception
*/
public static void simulationKey() throws Exception{
Robot rb = new Robot();
rb.delay(2*1000);
rb.keyPress(KeyEvent.VK_ENTER);
rb.keyRelease(KeyEvent.VK_ENTER);
int[] ks = {KeyEvent.VK_0,KeyEvent.VK_0,KeyEvent.VK_1,KeyEvent.VK_A};
for(int i=0; i < ks.length;i++){
rb.keyPress(ks[i]);
rb.delay(10);
rb.keyRelease(ks[i]);
rb.delay(10);
}
}
/**
* 模拟鼠标坐标
*
* @throws Exception
*/
public static void simulationMouseCoordinate()throws Exception{
Robot rb = new Robot();
rb.delay(2*1000);
int x = 200;
int y = 200;
//鼠标移动到开始菜单,
rb.mouseMove(x,y);
rb.delay(500);
}
/**
* 模拟鼠标点击
*
* @throws Exception
*/
public static void simulationMouseClick()throws Exception{
Robot rb = new Robot();
rb.delay(2*1000);
rb.mousePress(InputEvent.BUTTON2_MASK);
rb.delay(10);
rb.mouseRelease(InputEvent.BUTTON2_MASK);
rb.delay(2*1000);
rb.mousePress(InputEvent.BUTTON3_MASK);
rb.delay(10);
rb.mouseRelease(InputEvent.BUTTON3_MASK);
rb.delay(20);
}
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
//simulationKey();
//simulationMouseCoordinate();
simulationMouseClick();
}
}