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();
            }


    }
}

上一篇:android 多线程实现方式、并发与同步学习总结


下一篇:jqurey事件(4)