1.打开微信窗口
publicvoidopenWeChat() { //判断当前系统释放支持Desktop提供的接口if (Desktop.isDesktopSupported()) { try { //打开微信窗口desktop.open(newFile("C:\\Program Files (x86)\\Tencent\\WeChat\\WeChat.exe")); } catch (IOExceptione) { e.printStackTrace(); } } }
2.选择好友
publicvoidChooseFriends(Stringname) { Transferabletext=newStringSelection(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.发消息
publicvoidSendMessage(Stringmessage) { Transferabletext=newStringSelection(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); }
写出来了虽然但是基本上没什么用处哈哈哈哈...算是纪念品了。