当前位置:网站首页>通过程序启动QQ,实现自动登录.
通过程序启动QQ,实现自动登录.
2022-06-11 02:43:00 【shlyyy】
解决方案:
1、CreateProcess创建进程
2、找到QQ窗口3、设置鼠标位置至账号编辑框,点击聚焦4、模拟键盘输入账号5、设置鼠标位置至密码编辑框,点击聚焦6、模拟键盘输入密码
7、设置鼠标位置至密码编辑框,点击聚焦
8、模拟鼠标单击登录
这里从简,QQ打开以后,账号密码都记住了,所以免去了步骤3到步骤6。
其中,模拟鼠标的函数时mouse_event。模拟键盘的函数是keybd_event,自己百度一下就可以了。
示例代码
#include <windows.h>
#include <TCHAR.h>
//隐藏控制台
#pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
int main()
{
STARTUPINFO si = {
0 };
PROCESS_INFORMATION pi;
si.cb = sizeof(si);
BOOL res = CreateProcess(
TEXT("D:\\Program Files (x86)\\Tecent\\Tecent QQ\\Bin\\QQ.exe"),
NULL,
NULL,
NULL,
FALSE,
CREATE_NEW_CONSOLE,
NULL,
NULL, &si, &pi);
TCHAR szTitle[MAX_PATH] = {
0 };
HWND hwnd = FindWindow(TEXT("TXGuiFoundation"), TEXT("QQ"));
BOOL bOpened = FALSE;
DWORD i = 0;
for (i = 0; i < 100; i++)
{
if (hwnd != NULL)
{
bOpened = TRUE;
RECT r;
GetWindowRect(hwnd, &r);
//鼠标聚焦到输入密码编辑框
// ::SetCursorPos(r.left + 170, r.top + 295);
// mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); //点下左键
// mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //松开左键
// keybd_event(97, 0, 0, 0);
// keybd_event(97, 0, KEYEVENTF_KEYUP, 0);
// Sleep(50);
SetCursorPos(r.left + 170, r.top + 350);
//鼠标聚焦以后停3s等待QQ窗口弹出在点击登录按钮
Sleep(3000);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); //点下左键
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //松开左键
break;
}
else
{
hwnd = FindWindow(TEXT("TXGuiFoundation"), TEXT("QQ"));
Sleep(5);
}
}
return 0;
}
边栏推荐
- Three ways of reflection
- B / Qurt Utilisateur Guide (19)
- CPT 102_ LEC 13-14
- Go quick start of go language (I): the first go program
- Cypress 88359 WL command enable hotspot
- Baidu submits sitemap to prompt the solution of "index type is not handled"
- B_QuRT_User_Guide(16)
- Array full permutation
- VMware虚拟机IP,网关设置。虚拟机ping不通外网
- [new open source project] dynamic configuration task scheduling framework gobrs async joins the dromara open source community
猜你喜欢

Arduino uses nRF24L01 module for wireless communication

Unity项目优化详解(持续补充ing)

How to handle error code 30204-44 when installing office 2016 in win10?

第七章 常用的协议简介(1)

TCP/IP

完成千万元A轮融资,小象生活能否成为折扣界的“永辉”?

Win10 安装Office 2016出现错误代码30204-44怎么处理?

CPT 102_ LEC 16

GraphAcademy 課程講解:《Neo4j 圖數據科學基礎》

新来的同事问我 where 1=1 是什么意思???
随机推荐
Cygwin reports an error child_ info_ fork::abort: XXX. dll: Loaded to different address: parent(XXX) != child(XXX)
AOSP ~ 修改默认音量
Log4j:error category option "1" not a decimal integer
【长时间序列预测】Aotoformer 代码详解之[3]模型整体架构分析
How to use phpMyAdmin to optimize MySQL database
怎样确保消息的可靠性投递?
HUST Software Engineering (Experiment 2) -- TDD test driven development experiment.
How to fix syntax errors in WordPress websites
MySQL is required to sort in ascending order greater than or equal to the current time, and then in descending order less than the current time
Net core Tianma XingKong series - Interface Implementation for dependency injection and mutual conversion of database tables and C entity classes
Niuke: two numbers that only appear once in the array
Explication du cours de graphacademy: neo4j Graph Data Science Foundation
DNS Optimization Practice of APP network optimization
Forest v1.5.22 release! Kotlin support
数组全全排列
Prophet
Stringutils string tool class used by FreeMarker to create templates
从绿联冲刺IPO,看手机配件市场沉浮录
Prophet
20220610 Friday