1、设置剪切板内容(添加随机数字防止被禁言) int CChatDlg::SetData(CString str) { if(OpenClipboard()) { CString strTemp; HANDLE hClip; char* pBuf; // 清空剪切版、产生随机数字 EmptyClipboard(); strTemp.Format("%s%d %d",str,rand()%10,nTotal); // 打开剪切版、设置内容 hClip = GlobalAlloc(GMEM_MOVEABLE,strTemp.GetLength()+1); pBuf = (char*)GlobalLock(hClip); strcpy(pBuf,strTemp); GlobalUnlock(hClip); SetClipboardData(CF_TEXT,hClip); CloseClipboard(); // 计数器自加 m_nCount++; nTotal++; return 1; } return 0; } 2、粘贴文本到指定位置 int CChatDlg::PasteData() { CString strMy = "【泡泡堂大厅刷屏助手V1.0】网址: http://ningyu.m5t.de/Index.html "; HWND hWnd = ::FindWindow(NULL,_T("泡泡堂")); if(hWnd) { int nTemp = nTotal%5; if( nTemp == 0) { Sleep(2500); SetData(strMy); Sleep(10); ::PostMessage(hWnd,WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(370,540)); ::PostMessage(hWnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELONG(370,540)); ::PostMessage(hWnd,WM_LBUTTONUP,MK_LBUTTON, MAKELONG(370,540)); Sleep(100); ::PostMessage(hWnd,WM_KEYDOWN,VK_CONTROL,0x001D0001); ::PostMessage(hWnd,WM_CHAR,0x00000016,0x002F0001); Sleep(100); ::PostMessage(hWnd,WM_KEYUP,'V'/*0x00000056*/,0xC02F0001); ::PostMessage(hWnd,WM_KEYUP,VK_CONTROL,0xC01D0001); Sleep(200); SendEnter(); m_nTotal = 0; } Sleep(2500); UpdateData(TRUE); if(SetData(m_Edit1)) { ::PostMessage(hWnd,WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(370,540)); ::PostMessage(hWnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELONG(370,540)); ::PostMessage(hWnd,WM_LBUTTONUP,MK_LBUTTON, MAKELONG(370,540)); Sleep(100); ::PostMessage(hWnd,WM_KEYDOWN,VK_CONTROL,0x001D0001); ::PostMessage(hWnd,WM_CHAR,0x00000016,0x002F0001); Sleep(100); ::PostMessage(hWnd,WM_KEYUP,'V'/*0x00000056*/,0xC02F0001); ::PostMessage(hWnd,WM_KEYUP,VK_CONTROL,0xC01D0001); Sleep(200); SendEnter(); } Sleep(2600); if(SetData(m_Edit2)) { ::PostMessage(hWnd,WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(370,540)); ::PostMessage(hWnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELONG(370,540)); ::PostMessage(hWnd,WM_LBUTTONUP,MK_LBUTTON, MAKELONG(370,540)); Sleep(10); ::PostMessage(hWnd,WM_KEYDOWN,VK_CONTROL,0x001D0001); ::PostMessage(hWnd,WM_CHAR,0x00000016,0x002F0001); Sleep(100); ::PostMessage(hWnd,WM_KEYUP,'V'/*0x00000056*/,0xC02F0001); ::PostMessage(hWnd,WM_KEYUP,VK_CONTROL,0xC01D0001); Sleep(200); SendEnter(); } } }