<p>从技术角度研究QQ尾巴</p><p>1.获取qq聊天窗口句柄,利用VC++提供的Spy++可以查看到QQ窗口句柄</p><p> CWnd* pMainWnd=AfxGetMainWnd()->GetWindow(GW_HWNDFIRST); <br/> while(pMainWnd)<br/> { <br/> HWND hWnd;<br/> hWnd = pMainWnd->m_hWnd;<br/> pMainWnd->GetWindowText(str);<br/> if(str.Find ("聊天")>-1)<br/> {<br/> MainHWnd = hWnd;<br/> dwThreadID = GetWindowThreadProcessId(hWnd, NULL);<br/> MessageBox("OK");<br/> break;<br/> }<br/> else pMainWnd = pMainWnd->GetWindow(GW_HWNDNEXT); //继续找<br/> }</p><p></p><p>2.设置钩子,钩住你的发送按钮</p><p> g_QQProcTail=(struct HHOOK__*)SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,(struct HINSTANCE__ *)pChildWnd,dwThreadID);<br/> g_QQKeyTail=(struct HHOOK__*)SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,(struct HINSTANCE__ *)pChildWnd,dwThreadID);</p><p>3.截获你的发送信息,发送 BM_CLICK 消息</p><p> //找到消息填写控件<br/> CRichEditCtrl* pRich=(CRichEditCtrl*)(CWnd::FromHandle(hNext));<br/> pRich->GetWindowText (str);<br/> pRich->SetSel (nLen,nLen);<br/> CString strText;<br/> GetDlgItemText(IDC_TEXT,strText);<br/> pRich->ReplaceSel (strText);//填上将要发送的内容<br/><br/> //找消息发送按钮<br/> hWnd=FindWindowEx(pMainWnd->m_hWnd,NULL,NULL,NULL);<br/> while (hWnd) {<br/> pChildWnd=CWnd::FromHandle(hWnd); <br/> pChildWnd->GetWindowText(str);<br/> if(str.Find ("发送")>-1){<br/> pChildWnd->SendMessage (BM_CLICK);//发送</p> |