Java 通过JNA 调用Windows Api - 自动发送微信消息给指定用户

所需依赖: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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值