packageclick;importjava.awt.AWTException;importjava.awt.MouseInfo;importjava.awt.Point;importjava.awt.Robot;importjava.awt.event.InputEvent;importjava.awt.event.KeyEvent;importjava.io.BufferedReader;importjava.io.InputStreamReader;importjava.util.Properties;importcom.jcraft.jsch.ChannelExec;importcom.jcraft.jsch.JSch;importcom.jcraft.jsch.JSchException;importcom.jcraft.jsch.Session;public classclick {public static void main(String[] args) throwsException {//获取鼠标位置//for(int i=0;i<10;i++){//Point point = MouseInfo.getPointerInfo().getLocation();//System.out.println(“x=” + point.getX() + “,y=”+ point.getY());//Thread.sleep(3000);//}
Robot robot = null;
robot= newRobot();int x=298;int y = 133;for(int i=0;i<500;i++)
{if(i%20 ==0){
String cmdStop= “service activator stop”;
String cmdStart= “service activator start”;newclick().sendCommand(cmdStop);
Thread.sleep(180000);newclick().sendCommand(cmdStart);
Thread.sleep(180000);
Thread.sleep(3000);int jobx = 1333;int joby = 634;
robot.mouseMove(jobx,joby);
robot.mousePress(InputEvent.BUTTON1_MASK);//模拟鼠标松开左键
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
System.out.println(“—————-“);
}
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_MASK);//模拟鼠标松开左键
robot.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(120000);
System.out.println(“—-“+i);
}
}public void sendCommand(String cmd) throwsException {
System.out.println(cmd);
String userName=”root”;
String pass=”NFVD1234″;
String ip=”16.17.101.33″;
JSch sshSingleton= newJSch();
Session session=sshSingleton.getSession(userName, ip);
session.setPassword(pass);
Properties config= newProperties();
config.put(“StrictHostKeyChecking”, “no”);
session.setConfig(config);
session.connect();
ChannelExec channel= (ChannelExec) session.openChannel(“exec”);
BufferedReader in= new BufferedReader(newInputStreamReader(
channel.getInputStream()));
channel.setCommand(cmd);
channel.connect();//读取命令输出信息
String msg;while ((msg = in.readLine()) != null) {
System.out.println(msg);
}
channel.disconnect();
session.disconnect();
}
}