c++版思路:
(1)启动QQ主程序
WinExec(strLoc,SW_HIDE); // strLoc为QQ程序地址
(2)找到登录窗口
pWnd = FindWindow(_T("#32770"), _T("QQ用户登录"));
(3) 找到QQ号码输入窗口并输入号码 (利用剪切板复制粘贴QQ号码)
2 if (pCob)
3 {
4 //CString source;
5 if(OpenClipboard())
6 {
7 HGLOBAL clipbuffer;
8 char *buffer;
9 EmptyClipboard();
10 clipbuffer=GlobalAlloc(GMEM_DDESHARE,m_strCode.GetLength()+1);
11 buffer=(char *)GlobalLock(clipbuffer);
12 strcpy(buffer,LPCSTR(m_strCode));
13 GlobalUnlock(clipbuffer);
14 SetClipboardData(CF_TEXT,clipbuffer);
15 CloseClipboard();
16 }
17 pCob->SetCurSel(0);
18 pCob->DeleteString(0);
19 pCob->SendMessage(WM_PASTE, 0, 0);
20}
2 if (pCob)
3 {
4 if (pCob->GetCurSel()==CB_ERR)
5 {
6 pCob->SetCurSel(0);
7 }
8 }
9
10 CWnd *pCwnd = pWnd->GetNextWindow(GW_CHILD);
11 pCwnd = pCwnd->GetNextWindow(GW_HWNDNEXT);
12 while (pCwnd != NULL)
13 {
14 if (pCwnd)//找到
15 {
16 CEdit *pPwd = (CEdit *)pCwnd->GetDlgItem(16038);
17 if (pPwd)
18 {
19 char buf[20];
20 memset(buf, 0, sizeof(buf));
21 int iRet = m_strPassword.GetLength();
22 pPwd->SetSel(0, -1);
23 pPwd->Clear();
24
25 i = 0;
26 while (i < iRet)
27 {
28 pPwd->SendMessage(WM_CHAR, (WPARAM)m_strPassword.GetAt(i), 0);
29 i++;
30 }
31 break;
32 }
33 }
34 pCwnd = pCwnd->GetNextWindow(GW_HWNDNEXT);
35 }
2 if (pbtn)
3 {
4 if (QQInfo.type!=pbtn->GetCheck())
5 {
6 pbtn->PostMessage(WM_LBUTTONDOWN, 0, 0);
7 pbtn->PostMessage(WM_LBUTTONUP, 0, 0);
8 }
9 }
10
11 CButton *pbtnLogin = (CButton *)pWnd->GetDlgItem(16032);
12 if (pbtnLogin)
13 {
14 pbtnLogin->PostMessage(WM_LBUTTONDOWN, 0, 0);
15 pbtnLogin->PostMessage(WM_LBUTTONUP, 0, 0);
16 }