Qt5 模拟鼠标点击

6 篇文章 0 订阅

windows官方说明:https://docs.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-mouse_event?redirectedfrom=MSDN

参考自:https://www.fearlazy.com/index.php/post/168.html

做一个游戏辅助,使用Windows API鼠标自动在某一个坐标点击。

//头文件
#include<Windows.h>
#pragma comment(lib, "User32.lib")

QDesktopWidget *desktopwidget = QApplication::desktop();
int desktop_width = desktopwidget->width();  //获取屏幕分辨率宽度
int desktop_height = desktopwidget->height();  //获取屏幕分辨率高度
int stronghold_height = desktop_height * 0.68;  //要点击鼠标的位置在屏幕一定比例的位置
int stronghold_width = desktop_width * 0.9;
::mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, stronghold_width * 65535 / 1366, stronghold_height * 65535 / 768,0 ,0);  //移动到指定位置
::mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);  //按下左键
::mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);  //左键抬起

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值