package com.yh.proxy.pay.util;

import lombok.SneakyThrows;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.KeyEvent;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @title: qq
 * @Author kunkun
 * @Date: 2022/3/24 13:57
 * @Version 1.0
 */
public class qq {

    private static int maxThreads = 2;
    public static void main(String[] args) throws AWTException {
        Object o = new Object();
        ExecutorService es = new ThreadPoolExecutor(maxThreads, maxThreads, 1L, TimeUnit.MINUTES,
                new ArrayBlockingQueue<Runnable>(maxThreads, true), new ThreadPoolExecutor.CallerRunsPolicy());
        while (true) {
            synchronized (o) {
                es.submit(new Thread(
                        new Runnable() {
                            @SneakyThrows
                            @Override
                            public void run() {
                                send();
                            }
                        }
                ));
            }
        }
    }

    public static void send() throws AWTException {
        String sentence ="??????";

        Robot robot = new Robot();

        robot.delay(3000);

        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

        String[] authon=sentence.split("[,]");

        for (int j = 0; j < 50; j++) {

            for (int i = 0; i < authon.length; i++) {

                String sentencet=authon[i];

                Transferable Ttest=new StringSelection(sentencet);

                clipboard.setContents(Ttest,null);

                robot.keyPress(KeyEvent.VK_CONTROL);// 按下Control键

                robot.keyPress(KeyEvent.VK_V);// 按下V键

                robot.keyRelease(KeyEvent.VK_CONTROL);// 释放ctrl按键

                robot.delay(100);// 延迟一秒再发送

                robot.keyPress(KeyEvent.VK_ENTER);// 回车

            }

        }


    }
}


上一篇 下一篇