Java Robot类 微信消息群发
作者:互联网
package com.zhiyou;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.sql.SQLOutput;
public class MassTexting {
public static void main(String[] args) throws AWTException {
MassTexting(200);
}
public static void MassTexting(int num) {
try {
Robot robot = new Robot();
// System.out.println("回到桌面");
// // 回到桌面界面
// robot.keyPress(KeyEvent.VK_WINDOWS);
// robot.keyPress(KeyEvent.VK_D);
//
// robot.keyRelease(KeyEvent.VK_D);
// robot.keyRelease(KeyEvent.VK_WINDOWS);
System.out.println("切换屏幕");
// 切换一次屏幕
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_TAB);
System.out.println("休眠2秒");
robot.delay(2000);
for (int i = 0; i < num; i++){
System.out.println("粘贴");
// 粘贴 新年快乐噢!
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_V);
System.out.println("发送消息");
// 发送消息
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
System.out.println("休眠2秒");
robot.delay(2000);
for(int j = 0; j < i; j++) {
// 下一个聊天窗口
System.out.println("往下走哦"+i+"个聊天窗口");
robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
}
System.out.println("运行结束");
}
}catch (AWTException e) {
e.printStackTrace();
}
}
}
标签:Java,KeyEvent,微信,keyPress,VK,robot,System,out,群发 来源: https://blog.csdn.net/White_i/article/details/122761578