java实现腾讯会议自动入会
由于口罩原因线上会议较多,还经常在午休等时间开始,所有就实现了一个java版的自动入会,原理是使用鼠标控制完成自动填充和点击。自己实现可以更简单一点直接先自己打开会议,把该输入的都弄好,直接让程序到点执行最后一步的点击加入就好了
效果动图(不太会做动图,导出的有点模糊):
完整代码:
package com.test.template.utils;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.time.LocalDateTime;
public class AwtUtils {
final static int DELAY = 1000;
public static void click(Robot rt, int x, int y) {
rt.mouseMove(-1, -1);
rt.delay(DELAY);
rt.mouseMove(x, y);
rt.delay(DELAY);
pressMouse(rt, InputEvent.BUTTON1_MASK);
}
public static void doubleClick(Robot rt, int x, int y) {
rt.mouseMove(-1, -1);
rt.delay(100);
rt.mouseMove(x, y);
pressMouse(rt, InputEvent.BUTTON1_MASK);
pressMouse(rt, InputEvent.BUTTON1_MASK);
}
public static void pressMouse(Robot rt, int m) {
rt.mousePress(m);
rt.delay(100);
rt.mouseRelease(m);
}
public static void outPut(String str, Robot rt) {
StringSelection selection = new StringSelection(str);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
keyPressWithCotrl(rt, KeyEvent.VK_V);
}
public static void keyPressWithCotrl(Robot rt, int key) {
rt.keyPress(KeyEvent.VK_CONTROL);
rt.keyPress(key);
rt.keyRelease(KeyEvent.VK_CONTROL);
rt.keyRelease(key);
rt.delay(DELAY);
}
public static void main(String[] args) throws InterruptedException {
String cmd = "D:\\txmeeting\\WeMeet\\WeMeet\\wemeetapp.exe";
String meetingId = "123456789";
String name = "test";
String exTime = "2022-09-29T09:17:00";
System.out.println("会议号:" + meetingId + "; 昵称:" + name + "; 预约时间:" + exTime);
int x1 = 628, y1 = 255;
int x2 = 640, y2 = 298;
int x3 = 768, y3 = 722;
LocalDateTime expectedTime = LocalDateTime.parse(exTime);
while (true) {
if (expectedTime.isBefore(LocalDateTime.now())) {
Runtime rt = Runtime.getRuntime();
Process p = null;
try {
p = rt.exec(cmd);
System.out.println("正在启动应用程序……");
Thread.sleep(5000L);
Robot root = new Robot();
System.out.println("加入会议……");
click(root, x1, y1);
Thread.sleep(1000L);
click(root, x1, y1);
Thread.sleep(1000L);
System.out.println("输入会议号:" + meetingId);
outPut(meetingId, root);
Thread.sleep(1000L);
doubleClick(root, x2, y2);
Thread.sleep(500L);
System.out.println("输入会议昵称:" + name);
outPut(name, root);
Thread.sleep(500L);
click(root, x3, y3);
System.out.println("启动成功!");
break;
} catch (Exception e) {
e.printStackTrace();
System.out.println("启动过程出错!");
}
}
Thread.sleep(1000L);
}
}
}
以上就是所有实现,各位可以根据自己的需求进行调整,参考博客:https://blog.csdn.net/Wang_White_Pony/article/details/119736326