1.打开微信窗口
public void openWeChat() {//判断当前系统释放支持Desktop提供的接口if (Desktop.isDesktopSupported()) {try {
//打开微信窗口desktop.open(new File("C:\\Program Files (x86)\\Tencent\\WeChat\\WeChat.exe"));} catch (IOException e) {e.printStackTrace();}}}
2.选择好友
public void ChooseFriends(String name) {Transferable text = new StringSelection(name);clip.setContents(text, null);bot.delay(1000);bot.keyPress(KeyEvent.VK_CONTROL);bot.keyPress(KeyEvent.VK_F);bot.keyRelease(KeyEvent.VK_CONTROL);bot.delay(1000);bot.keyPress(KeyEvent.VK_CONTROL);bot.keyPress(KeyEvent.VK_V);bot.keyRelease(KeyEvent.VK_CONTROL);bot.delay(2000);bot.keyPress(KeyEvent.VK_ENTER);}
3.发消息
public void SendMessage(String message) {Transferable text = new StringSelection(message);clip.setContents(text, null);bot.delay(1000);bot.keyPress(KeyEvent.VK_CONTROL);bot.keyPress(KeyEvent.VK_V);bot.keyRelease(KeyEvent.VK_CONTROL);bot.delay(1000);bot.keyPress(KeyEvent.VK_ENTER);bot.delay(1000);bot.keyPress(KeyEvent.VK_CONTROL);bot.keyPress(KeyEvent.VK_ALT);bot.keyPress(KeyEvent.VK_W);bot.keyRelease(KeyEvent.VK_CONTROL);bot.keyRelease(KeyEvent.VK_ALT);
}