标签:select 代码 nts cti ble release pack 字符串 contents
package com.jie;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.KeyEvent;
/**
* @author wei zhijie
* @version 1.0
* @date 2021/1/9
*/
public class qq {
public static void main(String[] args) 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);
// 按下了ctrl+v,完成粘贴功能
robot.keyPress(KeyEvent.VK_CONTROL);// 按下Control键
robot.keyPress(KeyEvent.VK_V);// 按下V键
robot.keyRelease(KeyEvent.VK_CONTROL);// 释放ctrl按键
robot.delay(500);// 延迟一秒再发送
robot.keyPress(KeyEvent.VK_ENTER);// 回车
}
}
}
}
结果
发送成功
标签:select 代码 nts cti ble release pack 字符串 contents
原文地址:https://www.cnblogs.com/xiaozhounandu/p/14255254.html