void CSteamProto::OnGotHistoryMessages(const HttpResponse *response, void *arg) { MCONTACT hContact = FindContact((char*)arg); if (!hContact) return; if (!ResponseHttpOk(response)) return; JSONROOT root(response->pData); if (root == NULL) return; JSONNode *node = json_get(root, "response"); JSONNode *messages = json_get(node, "messages"); JSONNode *nmessages = json_as_array(messages); // Self SteamID ptrA steamId(getStringA("SteamID")); for (size_t i = json_size(nmessages); i > 0; i--) { JSONNode *message = json_at(nmessages, i - 1); node = json_get(message, "accountid"); const char *authorSteamId = AccountIdToSteamId(_ttoi64(ptrT(json_as_string(node)))); node = json_get(message, "message"); ptrT text(json_as_string(node)); T2Utf szMessage(text); node = json_get(message, "timestamp"); time_t timestamp = _ttoi64(ptrT(json_as_string(node))); // Ignore already existing messages if (timestamp <= m_lastMessageTS) continue; PROTORECVEVENT recv = { 0 }; recv.timestamp = timestamp; recv.szMessage = szMessage; if (strcmp(steamId, authorSteamId)) { // Received message ProtoChainRecvMsg(hContact, &recv); } else { // Sent message recv.flags = PREF_SENT; Proto_RecvMessage(hContact, &recv); } } json_delete(nmessages); }
DWORD CInputManager::OnLoadKeyBinding(DWORD msgSize, void *param) { IHashString *szhFileName; VERIFY_MESSAGE_SIZE(msgSize, sizeof(IHashString*)); szhFileName = (IHashString*)param; StdString szNodeName; IXMLArchive *Archive; CHashString streamType(_T("File")); CREATEARCHIVE ca; DWORD retVal = MSG_NOT_HANDLED; ca.streamData = (void*)szhFileName->GetString(); ca.mode = STREAM_MODE_READ; ca.streamType = &streamType; // call the Archive factory to create an XML archive static DWORD msgHash_CreateXMLArchive = CHashString(_T("CreateXMLArchive")).GetUniqueID(); if (retVal = m_ToolBox->SendMessage(msgHash_CreateXMLArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED) { //log error m_ToolBox->SetErrorValue(WARN_INVALID_OPERATION); m_ToolBox->Log(LOGWARNING, _T("CInputManager: Could not create archive from: %s\n"), szhFileName->GetString()); return MSG_NOT_HANDLED; } Archive = dynamic_cast<IXMLArchive *>(ca.archive); int num; CHashString curKeyBind(_T("")); StdString keybindName; StdString parentType; StdString childType; StdString msg; int key; bool hitOnce; Archive->GetNode(szNodeName); Archive->Read(keybindName, _T("name")); Archive->Read(num, _T("num")); curKeyBind = keybindName.c_str(); while (num != 0) { Archive->Read( msg, _T("msg") ); Archive->Read( key, _T("key") ); Archive->Read( hitOnce, _T("hitOnce") ); //Add Entry to page CHashString szMessage(msg); KEYBINDINGMAP &curPage = m_KeyMap[ curKeyBind.GetUniqueID() ]; curPage[ key ].msg = szMessage.GetUniqueID(); curPage[ key ].hitOnce = hitOnce; num--; } Archive->Close(); return MSG_HANDLED_STOP; }
void CSkypeProto::OnSendChatMessage(const TCHAR *chat_id, const TCHAR * tszMessage) { if (!IsOnline()) return; ptrA szChatId(mir_t2a(chat_id)); ptrA szMessage(mir_utf8encodeT(tszMessage)); if (strncmp(szMessage, "/me ", 4) == 0) SendRequest(new SendChatActionRequest(m_szRegToken, szChatId, time(NULL), szMessage, m_szServer)); else SendRequest(new SendChatMessageRequest(m_szRegToken, szChatId, time(NULL), szMessage, m_szServer)); }
// send the broadcast message to all selected users void lmcBroadcastWindow::sendMessage(void) { // return if text box is empty if(ui.txtMessage->document()->isEmpty()) return; // send only if connected if(bConnected) { QString szHtmlMessage(ui.txtMessage->toHtml()); encodeMessage(&szHtmlMessage); QTextDocument docMessage; docMessage.setHtml(szHtmlMessage); QString szMessage(docMessage.toPlainText()); // send broadcast int sendCount = 0; XmlMessage xmlMessage; xmlMessage.addData(XN_BROADCAST, szMessage); for(int index = 0; index < ui.tvUserList->topLevelItemCount(); index++) { for(int childIndex = 0; childIndex < ui.tvUserList->topLevelItem(index)->childCount(); childIndex++) { QTreeWidgetItem* item = ui.tvUserList->topLevelItem(index)->child(childIndex); if(item->checkState(0) == Qt::Checked) { QString szUserId = item->data(0, IdRole).toString(); emit messageSent(MT_Broadcast, &szUserId, &xmlMessage); sendCount++; } } } if(sendCount == 0) { QMessageBox::warning(this, tr("No recipient selected"), tr("Please select at least one recipient to send a broadcast.")); return; } ui.txtMessage->clear(); close(); } }
void CNetworkManager::Connect(const char*szHost, unsigned int uiPort, const char*szNickName) { // Safe disconnect. if ( IsConnected() ) Disconnect(); //przypisanie danych m_uiPort = uiPort; m_strHost.Set(szHost); // Startup RakNet. m_pRakPeer->Startup(1, &RakNet::SocketDescriptor(), 1); // Clear server address. m_ServerAddress = RakNet::UNASSIGNED_SYSTEM_ADDRESS; // Attach RPC4 to RakPeer. m_pRakPeer->AttachPlugin(m_pRPC4); //m_pRPCManager = new CRPCManager(m_pRakPeer); // Initialize PacketManager handler. m_pPacketManager = new CPacketManager(m_pRPC4/*m_pRPCManager*/); // Install RPC4 Packets. m_pPacketManager->Install(); // Message "Connection to IP:PORT..." CString szMessage("£¹czenie z ip %s:%d..", szHost, uiPort, szNickName); g_pClient->GetChatbox()->AddChatMessage(szMessage.Get(), 0xFF0000FF); // Ustawianie nicku. m_pPlayerManager->GetLocalPlayer()->SetName(CString(szNickName)); // Connecting m_pRakPeer->Connect(m_strHost.Get(), m_uiPort, NULL, NULL); }
void CSteamProto::ParsePollData(JSONNode *data) { JSONNode *node, *item = NULL; std::string steamIds; for (size_t i = 0; i < json_size(data); i++) { item = json_at(data, i); if (item == NULL) break; node = json_get(item, "steamid_from"); ptrA steamId(mir_t2a(ptrT(json_as_string(node)))); node = json_get(item, "utc_timestamp"); time_t timestamp = atol(ptrA(mir_t2a(ptrT(json_as_string(node))))); node = json_get(item, "type"); ptrT type(json_as_string(node)); if (!lstrcmpi(type, _T("saytext")) || !lstrcmpi(type, _T("emote")) || !lstrcmpi(type, _T("my_saytext")) || !lstrcmpi(type, _T("my_emote"))) { MCONTACT hContact = FindContact(steamId); if (!hContact) continue; node = json_get(item, "text"); ptrT text(json_as_string(node)); T2Utf szMessage(text); if (_tcsstr(type, _T("my_")) == NULL) { PROTORECVEVENT recv = { 0 }; recv.timestamp = timestamp; recv.szMessage = szMessage; ProtoChainRecvMsg(hContact, &recv); } else { AddDBEvent(hContact, EVENTTYPE_MESSAGE, timestamp, DBEF_UTF | DBEF_SENT, (int)mir_strlen(szMessage) + 1, (PBYTE)(char*)szMessage); } } else if (!lstrcmpi(type, _T("typing"))) { MCONTACT hContact = FindContact(steamId); if (hContact) { CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)STEAM_TYPING_TIME); } } else if (!lstrcmpi(type, _T("personastate"))) { node = json_get(item, "persona_state"); int status = node ? SteamToMirandaStatus(json_as_int(node)) : -1; if (IsMe(steamId)) { node = json_get(item, "persona_name"); setTString("Nick", ptrT(json_as_string(node))); if (status == -1 || status == ID_STATUS_OFFLINE) continue; if (status != m_iStatus) { debugLog(_T("CSteamProto::ParsePollData: Change own status to %i"), status); int oldStatus = m_iStatus; m_iStatus = m_iDesiredStatus = status; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); } continue; } MCONTACT hContact = FindContact(steamId); if (hContact == NULL) continue; // probably this is info about random player playing on same server, so we ignore it if (status != -1) SetContactStatus(hContact, status); node = json_get(item, "persona_name"); setTString(hContact, "Nick", ptrT(json_as_string(node))); // todo: find difference between state changing and info changing steamIds.append(steamId).append(","); } else if (!lstrcmpi(type, _T("personarelationship"))) { node = json_get(item, "persona_state"); int state = json_as_int(node); switch (state) { case 0: {// removed MCONTACT hContact = FindContact(steamId); if (hContact) { ContactIsRemoved(hContact); } } break; case 1: {// ignored MCONTACT hContact = FindContact(steamId); if (hContact) { ContactIsIgnored(hContact); } } break; case 2: {// auth request /*MCONTACT hContact = FindContact(steamId); if (!hContact) hContact = AddContact(steamId, true);*/ //RaiseAuthRequestThread((void*)hContact); ptrA token(getStringA("TokenSecret")); PushRequest( new GetUserSummariesRequest(token, steamId), &CSteamProto::OnAuthRequested, mir_strdup(steamId), MirFreeArg); } break; case 3: // add to list // todo break; default: continue; } } /*else if (!lstrcmpi(type, _T("leftconversation"))) { }*/ else { continue; } } if (!steamIds.empty()) { steamIds.pop_back(); ptrA token(getStringA("TokenSecret")); PushRequest( new GetUserSummariesRequest(token, steamIds.c_str()), &CSteamProto::OnGotUserSummaries); } }
Action::ResultE PostShaderStage::renderEnter(Action *action) { RenderAction *a = dynamic_cast<RenderAction *>(action); a->disableDefaultPartition(); this->beginPartitionGroup(a); { this->pushPartition(a); { RenderPartition *pPart = a->getActivePartition(); FrameBufferObject *pTarget = this->getRenderTarget(); Viewarea *pArea = a->getViewarea(); Camera *pCam = a->getCamera (); Background *pBack = a->getBackground(); if(pTarget == NULL) { this->initData(a); pTarget = this->getRenderTarget(); } pPart->setRenderTarget(pTarget); #ifdef OSG_DEBUGX std::string szMessage("RenderPartition\n"); pPart->setDebugString(szMessage ); #endif if(pArea != NULL) { // pPart->setViewport(pPort ); pPart->setWindow (a->getWindow()); if(pTarget != NULL) { #if 0 pPart->calcViewportDimension(pArea->getLeft (), pArea->getBottom(), pArea->getRight (), pArea->getTop (), pTarget->getWidth (), pTarget->getHeight ()); #endif pPart->calcViewportDimension(0.f, 0.f, 1.f, 1.f, pTarget->getWidth (), pTarget->getHeight ()); } else { pPart->calcViewportDimension(pArea->getLeft (), pArea->getBottom(), pArea->getRight (), pArea->getTop (), a->getWindow()->getWidth (), a->getWindow()->getHeight()); } if(pCam != NULL) { Matrix m, t; // set the projection pCam->getProjection (m, pPart->getViewportWidth (), pPart->getViewportHeight()); pCam->getProjectionTranslation(t, pPart->getViewportWidth (), pPart->getViewportHeight()); pPart->setupProjection(m, t); pCam->getViewing(m, pPart->getViewportWidth (), pPart->getViewportHeight()); pPart->setupViewing(m); pPart->setNear (pCam->getNear()); pPart->setFar (pCam->getFar ()); pPart->calcFrustum(); } pPart->setBackground(pBack); } this->recurseFromThis(a); } this->popPartition(a); this->pushPartition(a, (RenderPartition::CopyWindow | RenderPartition::CopyViewportSize), RenderPartition::SimpleCallback ); { RenderPartition *pPart = a->getActivePartition(); #ifdef OSG_DEBUGX std::string szMessage("PostProcessPartition\n"); pPart->setDebugString(szMessage ); #endif Matrix m, t; m.setIdentity(); t.setIdentity(); MatrixOrthogonal( m, 0.f, 1.f, 0.f, 1.f, -1.f, 1.f); pPart->setupProjection(m, t); RenderPartition::SimpleDrawCallback f; f = boost::bind(&PostShaderStage::postProcess, this, _1); pPart->dropFunctor(f); } this->popPartition(a); } this->endPartitionGroup(a); RenderPassVector::iterator passIt = _vPostProcessPasses.begin(); //Update the uniform parameters to the shader for(; passIt != _vPostProcessPasses.end(); ++passIt) { (*passIt)->updateUniformVariables(a); } return Action::Skip; }
Action::ResultE HDRStage::renderEnter(Action *action) { RenderAction *a = dynamic_cast<RenderAction *>(action); a->disableDefaultPartition(); Int32 iVPWidth = a->getActivePartition()->getViewportWidth (); Int32 iVPHeight = a->getActivePartition()->getViewportHeight(); this->beginPartitionGroup(a); { this->pushPartition(a); { RenderPartition *pPart = a ->getActivePartition(); FrameBufferObject *pTarget = this->getRenderTarget (); Viewarea *pArea = a ->getViewarea (); Camera *pCam = a ->getCamera (); Background *pBack = a ->getBackground (); if(pTarget == NULL) { this->initData(a, iVPWidth, iVPHeight); pTarget = this->getRenderTarget(); } else { this->updateData(a, iVPWidth, iVPHeight); } pPart->setRenderTarget(pTarget); pPart->getDrawEnv().setTargetBufferFormat(this->getBufferFormat()); #ifdef OSG_DEBUGX std::string szMessage("HDR: RenderPartition\n"); pPart->setDebugString(szMessage ); #endif if(pArea != NULL) { pPart->setWindow (a->getWindow()); if(pTarget != NULL) { #if 0 pPart->calcViewportDimension(pArea->getLeft (), pArea->getBottom(), pArea->getRight (), pArea->getTop (), pTarget->getWidth (), pTarget->getHeight ()); #endif pPart->calcViewportDimension(0.f, 0.f, 1.f, 1.f, pTarget->getWidth (), pTarget->getHeight ()); } else { pPart->calcViewportDimension(pArea->getLeft (), pArea->getBottom(), pArea->getRight (), pArea->getTop (), a->getWindow()->getWidth (), a->getWindow()->getHeight()); } if(pCam != NULL) { Matrix m, t; // set the projection pCam->getProjection (m, pPart->getViewportWidth (), pPart->getViewportHeight()); pCam->getProjectionTranslation(t, pPart->getViewportWidth (), pPart->getViewportHeight()); pPart->setupProjection(m, t); pCam->getViewing(m, pPart->getViewportWidth (), pPart->getViewportHeight()); pPart->setupViewing(m); pPart->setNear (pCam->getNear()); pPart->setFar (pCam->getFar ()); pPart->calcFrustum(); } pPart->setBackground(pBack); } this->recurseFromThis(a); } this->popPartition(a); a->getActivePartition()->disable(); this->pushPartition(a, (RenderPartition::CopyWindow | RenderPartition::CopyViewportSize | RenderPartition::CopyTarget ), RenderPartition::SimpleCallback ); { RenderPartition *pPart = a->getActivePartition(); #ifdef OSG_DEBUGX std::string szMessage("HDR: PostProcessPartition\n"); pPart->setDebugString(szMessage ); #endif Matrix m, t; m.setIdentity(); t.setIdentity(); MatrixOrthogonal( m, 0.f, 1.f, 0.f, 1.f, -1.f, 1.f); pPart->setupProjection(m, t); RenderPartition::SimpleDrawCallback f; f = boost::bind(&HDRStage::postProcess, this, _1); pPart->dropFunctor(f); } this->popPartition(a); } this->endPartitionGroup(a); return Action::Skip; }
void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) { if (response == NULL) return; JSONNode root = JSONNode::parse(response->pData); if (!root) return; const JSONNode &metadata = root["_metadata"]; const JSONNode &conversations = root["messages"].as_array(); int totalCount = metadata["totalCount"].as_int(); std::string syncState = metadata["syncState"].as_string(); bool markAllAsUnread = getBool("MarkMesUnread", true); if (totalCount >= 99 || conversations.size() >= 99) PushRequest(new GetHistoryOnUrlRequest(syncState.c_str(), li), &CSkypeProto::OnGetServerHistory); for (int i = (int)conversations.size(); i >= 0; i--) { const JSONNode &message = conversations.at(i); CMStringA szMessageId = message["clientmessageid"] ? message["clientmessageid"].as_string().c_str() : message["skypeeditedid"].as_string().c_str(); std::string messageType = message["messagetype"].as_string(); std::string from = message["from"].as_string(); std::string content = message["content"].as_string(); std::string conversationLink = message["conversationLink"].as_string(); int emoteOffset = message["skypeemoteoffset"].as_int(); time_t timestamp = IsoToUnixTime(message["composetime"].as_string().c_str()); CMStringA skypename(UrlToSkypename(from.c_str())); bool isEdited = message["skypeeditedid"]; MCONTACT hContact = FindContact(UrlToSkypename(conversationLink.c_str())); if (timestamp > db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0)) db_set_dw(hContact, m_szModuleName, "LastMsgTime", (DWORD)timestamp); int iFlags = DBEF_UTF; if (!markAllAsUnread) iFlags |= DBEF_READ; if (IsMe(skypename)) iFlags |= DBEF_SENT; if (strstr(conversationLink.c_str(), "/8:")) { if (messageType == "Text" || messageType == "RichText") { ptrA szMessage(messageType == "RichText" ? RemoveHtml(content.c_str()) : mir_strdup(content.c_str())); MEVENT dbevent = GetMessageFromDb(hContact, szMessageId); if (isEdited && dbevent != NULL) { AppendDBEvent(hContact, dbevent, szMessage, szMessageId, timestamp); } else AddDbEvent(emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, hContact, timestamp, iFlags, &szMessage[emoteOffset], szMessageId); } else if (messageType == "Event/Call") { AddDbEvent(SKYPE_DB_EVENT_TYPE_CALL_INFO, hContact, timestamp, iFlags, content.c_str(), szMessageId); } else if (messageType == "RichText/Files") { AddDbEvent(SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO, hContact, timestamp, iFlags, content.c_str(), szMessageId); } else if (messageType == "RichText/UriObject") { AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, iFlags, content.c_str(), szMessageId); } else if (messageType == "RichText/Contacts") { ProcessContactRecv(hContact, timestamp, content.c_str(), szMessageId); } else { AddDbEvent(SKYPE_DB_EVENT_TYPE_UNKNOWN, hContact, timestamp, iFlags, content.c_str(), szMessageId); } } else if (conversationLink.find("/19:") != -1) { CMStringA chatname(UrlToSkypename(conversationLink.c_str())); if (messageType == "Text" || messageType == "RichText") { AddMessageToChat(_A2T(chatname), _A2T(skypename), content.c_str(), emoteOffset != NULL, emoteOffset, timestamp, true); } } } }
ActionBase::ResultE CubeMapGenerator::renderEnter(Action *action) { static Matrix transforms[] = { Matrix( 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1), Matrix(-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), Matrix( 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1), Matrix( 1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1), Matrix( 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1), Matrix( 0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1) }; RenderAction *a = dynamic_cast<RenderAction *>(action); Action::ResultE returnValue = Action::Continue; Background *pBack = a->getBackground(); Viewport *pPort = a->getViewport(); Node *pActNode = a->getActNode(); CubeMapGeneratorStageData *pData = a->getData<CubeMapGeneratorStageData *>(_iDataSlotId); if(pData == NULL) { pData = this->initData(a); } TraversalValidator::ValidationStatus eStatus = this->validateOnEnter(a); if(eStatus == TraversalValidator::Run) { this->beginPartitionGroup(a); { FrameBufferObject *pTarget = this->getRenderTarget(); if(pTarget == NULL) { pTarget = pData->getRenderTarget(); } Pnt3f oOrigin; if(this->getOriginMode() == CubeMapGenerator::UseStoredValue) { oOrigin = this->getOrigin(); } else if(this->getOriginMode() == CubeMapGenerator::UseBeacon) { fprintf(stderr, "CubemapGen::UseBeacon NYI\n"); } else if(this->getOriginMode() == CubeMapGenerator::UseCurrentVolumeCenter) { BoxVolume oWorldVol; commitChanges(); pActNode->updateVolume(); pActNode->getWorldVolume(oWorldVol); oWorldVol.getCenter(oOrigin); } else if(this->getOriginMode() == CubeMapGenerator::UseParentsVolumeCenter) { fprintf(stderr, "CubemapGen::UseParentsCenter NYI\n"); } Camera *pCam = pData->getCamera(); pActNode->setTravMask(0); for(UInt32 i = 0; i < 6; ++i) { this->pushPartition(a); { RenderPartition *pPart = a->getActivePartition(); pPart->setVolumeDrawing(false); pPart->setRenderTarget(pTarget ); pPart->setWindow (a->getWindow()); pPart->calcViewportDimension(0, 0, 1, 1, this->getWidth (), this->getHeight()); Matrix m, t; // set the projection pCam->getProjection (m, pPart->getViewportWidth (), pPart->getViewportHeight()); pCam->getProjectionTranslation(t, pPart->getViewportWidth (), pPart->getViewportHeight()); pPart->setupProjection(m, t); m = transforms[i]; m[3][0] = oOrigin[0]; m[3][1] = oOrigin[1]; m[3][2] = oOrigin[2]; m.invert(); pPart->setupViewing(m); pPart->setNear (pCam->getNear()); pPart->setFar (pCam->getFar ()); pPart->calcFrustum(); if(this->getBackground() == NULL) { pPart->setBackground(pBack); } else { pPart->setBackground(this->getBackground()); } if(this->getRoot() != NULL) { this->recurse(a, this->getRoot()); } else { this->recurse(a, pPort->getRoot()); } pPart->setDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + i); #ifdef OSG_DEBUGX std::string szMessage("CubeX\n"); pPart->setDebugString(szMessage ); #endif } this->popPartition(a); } pActNode->setTravMask(~0); } this->endPartitionGroup(a); } OSG_ASSERT(pActNode == a->getActNode()); returnValue = Inherited::renderEnter(action); action->useNodeList(false); return returnValue; }
UINT CMessageSender::SendOneMsg() { // 发送消息窗口,正常情况应该出现该窗口 HWND hWndMsg = FindTopWindow(message.SendUserId.GetBuffer(), "StandardFrame"); // 找到正常窗口 if (hWndMsg != NULL) { // 消息内容窗口 HWND hSplitterBar = ::FindWindowEx(hWndMsg, NULL, "SplitterBar", ""); //HWND hHtmlEditor = FindChildWnd(hSplitterBar, "", "HtmlEditor"); HWND hMsgEdit = FindChildWnd(hSplitterBar, "", "RichEditComponent"); CString szMessage(message.MessageHtml); ::SendMessage(hMsgEdit, WM_SETTEXT , 0, (LPARAM)szMessage.GetBuffer()); // 添加任意字符,否则“发送”按钮是灰色不可点击 ::PostMessage(hMsgEdit, WM_KEYDOWN , '.', 0); ::PostMessage(hMsgEdit, WM_KEYUP , '.', 0); Sleep(200); // 点击发送按钮 HWND hbtnSend = ::FindWindowEx(hWndMsg, NULL, "StandardButton", "发送"); ::PostMessage(hbtnSend, WM_LBUTTONDOWN , 0, 0); ::PostMessage(hbtnSend, WM_LBUTTONUP , 0, 0); /* // 检查校验码 Sleep(2000); // 校验码窗口 HWND hValidCodeWnd = FindTopWindowExactly("阿里旺旺 - 安全验证", "#32770"); if (hValidCodeWnd) { char lpstrChkCode[32]; memset(lpstrChkCode,0, 32); HWND hValidCodeEdit = FindChildWnd(hValidCodeWnd, "", "EditComponent"); ::SendMessage(hValidCodeEdit, WM_GETTEXT, 32, (LPARAM)lpstrChkCode); while (hValidCodeWnd && hValidCodeEdit && strlen(lpstrChkCode) < 5) { Sleep(1000); hValidCodeWnd = FindTopWindowExactly("阿里旺旺 - 安全验证", "#32770"); hValidCodeEdit = FindChildWnd(hValidCodeWnd, "", "EditComponent"); ::SendMessage(hValidCodeEdit, WM_GETTEXT, 32, (LPARAM)lpstrChkCode); } HWND hValidCodeOK = FindChildWnd(hValidCodeWnd, "确定", "StandardButton"); ::PostMessage(hValidCodeOK, WM_LBUTTONDOWN , 0, 0); ::PostMessage(hValidCodeOK, WM_LBUTTONUP , 0, 0); HWND hValidCodeExp = FindChildWnd(hValidCodeWnd, "", "Internet Explorer_Server"); CoInitialize( NULL ); IHTMLDocument2 *pDoc; DWORD lRes; UINT MSG = RegisterWindowMessage("WM_HTML_GETOBJECT"); SendMessageTimeout(hValidCodeExp, MSG, 0, 0, SMTO_ABORTIFHUNG, 1000, &lRes); ObjectFromLresult(lRes, IID_IHTMLDocument2, 0, (void**)&pDoc); if (pDoc) { IHTMLElement* pChkBody; HRESULT re = pDoc->get_body(&pChkBody); if (pChkBody) { BSTR bstrHtml; pChkBody->get_innerHTML(&bstrHtml); CString szHtml(bstrHtml); if (!szHtml.IsEmpty()) { CString szUrl(""); int nStartUrl = 0, nEndUrl =0; nStartUrl = szHtml.Find("http://checkcode.alisoft.com/alisoft/checkcode?sessionID="); if (nStartUrl > 0) { nEndUrl = szHtml.Find("\"", nStartUrl); } if (nEndUrl > nStartUrl && nStartUrl >= 0) { szUrl = szHtml.Mid(nStartUrl, nEndUrl - nStartUrl); } if (!szUrl.IsEmpty()) { // 识别 CString checkCode = Recognize(szUrl); while (checkCode.IsEmpty()) { Sleep(1000); checkCode = Recognize(szUrl); } HWND hValidCodeEdit = FindChildWnd(hValidCodeWnd, "", "EditComponent"); ::SendMessage(hValidCodeEdit, WM_SETTEXT, 0, (LPARAM)checkCode.GetBuffer()); HWND hValidCodeOK = FindChildWnd(hValidCodeWnd, "确定", "StandardButton"); ::PostMessage(hValidCodeOK, WM_LBUTTONDOWN , 0, 0); ::PostMessage(hValidCodeOK, WM_LBUTTONUP , 0, 0); } } } } CoUninitialize(); }*/ // 关闭窗口 Sleep(400); ::PostMessage(hWndMsg, WM_CLOSE, 0, 0); } return 0; }