如何使用Java快速失去一个微信好友
使用要求
1.正常Java环境
2.电脑登录微信
代码
代码在最后,直接copy就行,都有注释,照着注释改main方法里的参数就好,
其他说明
嫌弃1秒发送一条太慢的话直接改waitTime的值,但是最好不要低于10ms,不然想要a发送10遍,b发送10遍的话,会造成a发送19遍,b发送1遍的效果,那既然都要失去这个微信好友了,为什么还要不同的句子呢,是因为快速给同一个微信好友发送同一条消息的时候,可能会发送失败,实测count这个参数最好不要超过60。如果这样都不删掉你,直接在第一层for循环外面在加一层死循环,电脑一放,跑他几天
package other;
/**
* Created with IntelliJ IDEA.
*
* @Auther: 小杨
* @Date: 2021/09/18/10:40
* @Description:
*/
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.KeyEvent;
/**
* @author xiaoyang
*/
public class SendWeChat {
public static void main(String[] args) throws InterruptedException {
// 好友昵称
String friendNickName = "文件传输助手";
//发送次数
int count=10;
//发送的内容,数组里每个值都会发送count遍
String[] mottoes = { "[奸笑]","哈哈"};
//发送消息的时间间隔
int waitTime=1000;
searchMyFriendAndSend(friendNickName,count,mottoes,waitTime);
}
private static void searchMyFriendAndSend(String friendNickName,int count,String[] mottoes,int waitTime) throws InterruptedException {
/*-----------------start 打开微信,找到要发送的好友---------------------------------------*/
// 创建Robot对象
Robot robot = getRobot();
//打开微信 Ctrl+Alt+W
assert robot != null;
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_W);
//释放Ctrl按键,像Ctrl,退格键,删除键这样的功能性按键,在按下后一定要释放
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_ALT);
// 该延迟不能少,否则无法搜索
robot.delay(1000);
// Ctrl + F 搜索指定好友
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_CONTROL);
// 将好友昵称发送到剪切板
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tText = new StringSelection(friendNickName);
clip.setContents(tText, null);
// 以下两行按下了ctrl+v,完成粘贴功能
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.delay(1000);
robot.keyPress(KeyEvent.VK_ENTER);
robot.delay(1000);
/*-----------------end 打开微信,找到要发送的好友---------------------------------------*/
// 发送消息
sendOneMsg(count,mottoes,waitTime);
}
private static void sendOneMsg(int count,String[] mottoes,int waitTime) {
Robot robot = getRobot();
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
for (String motto : mottoes) {
// 将字符串复制到剪切板
Transferable tText = new StringSelection(motto);
clip.setContents(tText, null);
// 以下两行按下了ctrl+v,完成粘贴功能
for (int i=1;i<=count;i++){
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
// 回车发送
robot.keyPress(KeyEvent.VK_ENTER);
robot.delay(waitTime);
}
}
}
private static Robot getRobot(){
// 创建Robot对象
Robot robot = null;
try {
robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
return robot;
}
}