【Funny Things】001——QQ循环发送消息
程序员文章站
2023-11-08 16:50:04
借用Java的Robot类库中的键鼠模拟的方法,执行这个操作,首先切换到QQ界面,然后循环粘贴,回车发送消息。 ......
借用java的robot类库中的键鼠模拟的方法,执行这个操作,首先切换到qq界面,然后循环粘贴,回车发送消息。
package newtest; import java.awt.*; import java.awt.event.keyevent; public class keyboard { private robot robot = null; public keyboard(){ try{ robot = new robot(); }catch (awtexception a){ system.out.println(a.tostring()); } } //跳转到需要发送数据的页面,这里选用的是qq的界面 public void jump(){ robot.keypress(keyevent.vk_alt); robot.keypress(keyevent.vk_tab); robot.keyrelease(keyevent.vk_alt); robot.keyrelease(keyevent.vk_tab); } //循环发送剪贴板上的东西 public void send(){ for(int i=0;i<300;i++){ // robot.keypress(keyevent.vk_c); // robot.keyrelease(keyevent.vk_c); // robot.keypress(keyevent.vk_y); // robot.keyrelease(keyevent.vk_y); robot.keypress(keyevent.vk_control); robot.keypress(keyevent.vk_v); robot.keyrelease(keyevent.vk_control); robot.keyrelease(keyevent.vk_v); robot.delay(300); // robot.keypress(keyevent.vk_space); // robot.keyrelease(keyevent.vk_space); // // robot.delay(300); robot.keypress(keyevent.vk_enter); robot.keyrelease(keyevent.vk_enter); //设置延时,不然处理速度过快一下子发完了 robot.delay(500); } } public static void main(string[] args) { keyboard keyboard = new keyboard(); keyboard.jump(); keyboard.send(); } }