follow my heart...
分类: C/C++
2006-11-10 13:33:59
//找QQ的登陆对话框,如果QQ没有启动,则先启动它。 pWnd = FindWindow(_T("#32770"), _T("QQ用户登录")); if (!pWnd) { PROCESS_INFORMATION lpProcessInformation; STARTUPINFO startupinfo; memset(&startupinfo,0,sizeof(STARTUPINFO)); memset(&lpProcessInformation,0,sizeof(PROCESS_INFORMATION)); startupinfo.cb = sizeof(STARTUPINFO); startupinfo.dwFlags = STARTF_FORCEOFFFEEDBACK; startupinfo.dwX = 0; startupinfo.dwY = 0; startupinfo.lpDesktop = NULL; startupinfo.lpReserved = NULL; startupinfo.lpReserved2 = NULL; startupinfo.lpTitle = NULL; CreateProcess(_T("D:\\Tencent\\qq\\CoralQQ.exe"), NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &startupinfo, &lpProcessInformation); } |
if (pWnd) { //获得QQ的号码输入框指针 CComboBox *pCob = (CComboBox *)pWnd->GetDlgItem(138); if (pCob) { m_edtCode.SetSel(0, -1); m_edtCode.Copy(); //先删除原有号码后向号码输入框发送复制消息 pCob->SetCurSel(0); pCob->DeleteString(0); pCob->SendMessage(WM_PASTE, 0, 0); } //因为QQ的密码框是包含在主窗口里的子窗口,所以先获得子窗口后再一个个往后找 CWnd *pCwnd = pWnd->GetNextWindow(GW_CHILD); pCwnd = pCwnd->GetNextWindow(GW_HWNDNEXT); while (pCwnd != NULL) { if (pCwnd)//找到 { CEdit *pPwd = (CEdit *)pCwnd->GetDlgItem(16038); if (pPwd) { char cKey; char buf[20]; memset(buf, 0, sizeof(buf)); //因为我的程序是unicode,所以这里要转换。如果不是,则不用转换了。 int iRet = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, m_strPassword.GetBuffer(m_strPassword.GetLength()), m_strPassword.GetLength(), buf, 20, NULL, NULL); //清除密码框 pPwd->SetSel(0, -1); pPwd->Clear(); i = 0; //将密码一个个地发送过去。这里不能用复制消息,因为QQ的密码框不允许复制 while (i < iRet) { strncpy(&cKey, buf+i, 1); pPwd->SendMessage(WM_CHAR, (WPARAM)cKey, 0); i++; } break; } } pCwnd = pCwnd->GetNextWindow(GW_HWNDNEXT); } |
//以下为找到登陆按钮后,发送鼠标单击消息 CButton *pbtnLogin = (CButton *)pWnd->GetDlgItem(16032); if (pbtnLogin) { pbtnLogin->PostMessage(WM_LBUTTONDOWN, 0, 0); pbtnLogin->PostMessage(WM_LBUTTONUP, 0, 0); } |