QQ2013整个登陆界面采用一个子窗口,没有所谓的Edit控件等,界面元素估计都是画上去的,同时底层截取按键消息,保证密码的安全输入安全
因此要实现自动登录最好采用模拟鼠标,键盘等操作方式,mouse_event, keybd_event
借助spyxx分析QQ界面消息基本都是WM_PAINT.等等。。。
因此要实现自动登录最好采用模拟鼠标,键盘等操作方式,mouse_event, keybd_event
借助spyxx分析QQ界面消息基本都是WM_PAINT.等等。。。
等下来研究获取好友列表与自动加好友
大致实现如下:
HWND pQQWnd = NULL;
pQQWnd = FindWindow(NULL, TEXT("QQ"));
//定位QQ登录框焦点
::SetForegroundWindow(pQQWnd);
::SetFocus(pQQWnd);
RECT qqWRect, qqRect;
DWORD x, y;
GetWindowRect(pQQWnd, &qqWRect);
GetClientRect(pQQWnd, &qqRect);
x = qqWRect.left + qqRect.right / 2;
y = qqWRect.top + 225;
int screenwidth_real=GetSystemMetrics(SM_CXSCREEN);
int screenheight_real=GetSystemMetrics(SM_CYSCREEN);
DWORD x, y;
GetWindowRect(pQQWnd, &qqWRect);
GetClientRect(pQQWnd, &qqRect);
x = qqWRect.left + qqRect.right / 2;
y = qqWRect.top + 225;
int screenwidth_real=GetSystemMetrics(SM_CXSCREEN);
int screenheight_real=GetSystemMetrics(SM_CYSCREEN);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, (x - 10) * 65536 / screenwidth_real , y * 65536 / screenheight_real, 0, 0);
Sleep(200);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, x * 65536 / screenwidth_real , y * 65536 / screenheight_real, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Sleep(200);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Sleep(1000);
keybd_event(VK_BACK, 0, 0, 0);
keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
Sleep(100);
keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
Sleep(100);
//输入号码
PostMessage(pQQWnd, WM_CHAR, (TCHAR)'3', 0);
Sleep(100);
PostMessage(pQQWnd, WM_CHAR, (TCHAR)'0', 0);
Sleep(100);
PostMessage(pQQWnd, WM_CHAR, (TCHAR)'2', 0);
Sleep(100);
PostMessage(pQQWnd, WM_CHAR, (TCHAR)'9', 0);
Sleep(100);
PostMessage(pQQWnd, WM_CHAR, (TCHAR)'5', 0);
Sleep(100);
PostMessage(pQQWnd, WM_CHAR, (TCHAR)'3', 0);
Sleep(100);
PostMessage(pQQWnd, WM_CHAR, (TCHAR)'7', 0);
Sleep(100);
//密码输入
lParam = MAKELPARAM(244, 260);
SendMessage(pQQWnd, WM_LBUTTONDOWN, MK_LBUTTON, lParam);
Sleep(1000);
SendMessage(pQQWnd, WM_LBUTTONUP, MK_LBUTTON, lParam);
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(56, 0, 0, 0); //密码
keybd_event(56, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
Sleep(100);
keybd_event(56, 0, 0, 0);//密码。。。
keybd_event(56, 0, KEYEVENTF_KEYUP, 0);
Sleep(100);
。。。。。。。。。。。。
//登录按钮单击
lParam = MAKELPARAM(216, 340);
SendMessage(pQQWnd, WM_LBUTTONDOWN, 0, lParam);
SendMessage(pQQWnd, WM_LBUTTONUP, 0, lParam);
keybd_event(56, 0, 0, 0); //密码
keybd_event(56, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
Sleep(100);
keybd_event(56, 0, 0, 0);//密码。。。
keybd_event(56, 0, KEYEVENTF_KEYUP, 0);
Sleep(100);
。。。。。。。。。。。。
//登录按钮单击
lParam = MAKELPARAM(216, 340);
SendMessage(pQQWnd, WM_LBUTTONDOWN, 0, lParam);
SendMessage(pQQWnd, WM_LBUTTONUP, 0, lParam);