所需依赖:jna-5.4.0.jar 和 jna-platform-5.4.0.jar
下载地址:https://github.com/java-native-access/jna
首先需要将微信置顶层:
WinDef.HWND hwnd = User32.INSTANCE.FindWindow(null, "微信");
if (hwnd == null) {
System.out.println("not running");
} else {
User32.INSTANCE.ShowWindow(hwnd, 9);
User32.INSTANCE.SetForegroundWindow(hwnd); // bring to front
}
使用Robot类 模拟安键输入Ctrl+F和Enter查找指定用户
static Robot robot;
static {
try {
if (robot == null)
robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
}
将需要输入的内容复制到裁剪版
public static void copy(String text) {
Clipboard sysc = Toolkit.getDefa