Comment
Author: Admin | 2025-04-27
Std;void MyMainWorker::doRegDM(Idmsoft **pDm) { cout "========== Initial DM ............ ==========" endl; *pDm = initialDMAndRegVIP(); if (*pDm == nullptr) { cout "========== Initial DM ==========" endl; emit this->regDMReady(false, "DM 注册失败!"); return; } cout "========== Initial DM ==========" endl; cout endl; emit this->regDMReady(true, "DM 注册完成!");}void MyMainWorker::doFindWindow(Idmsoft *pDm, const QString &title) { vectorMyWindow> windowVec; if (pDm == nullptr) { cout "this->pCommonDm == nullptr" endl; emit this->findWindowReady(false, "请先在菜单中完成注册!", windowVec); return; } // 找一下包含title的窗口 getMatchedWindows(windowVec, pDm, title.toStdWString()); if (windowVec.empty()) { cout "can not find such window" endl; emit this->findWindowReady(false, "没有找到包含该标题的窗口!", windowVec); return; } emit this->findWindowReady(true, "成功!", windowVec);}void MyMainWorker::doCaptureWindow(Idmsoft *pDm, long hwnd) { if (pDm == nullptr) { cout "this->pCommonDm == nullptr" endl; emit this->captureWindowReady(false, "请先在菜单中完成注册!"); return; } // 绑定窗口句柄 long dmBind = pDm->BindWindowEx( hwnd, "normal", "normal", "normal", "", 0 ); if (dmBind == 1) { // 恢复并激活指定窗口,置顶窗口, pDm->SetWindowState(hwnd, 12); pDm->SetWindowState(hwnd, 8); pDm->delay(600); // 延迟一下截图,存到相对路径 wstring filename = wstring(L"./capture_window_").append(std::to_wstring(hwnd)).append(L".bmp"); long retCap = pDm->Capture(0, 0, 2000, 2000, filename.c_str()); if (retCap != 1) { cout "capture failed" endl; emit this->captureWindowReady(false, "截图失败!"); } else { cout "capture success" endl; emit this->captureWindowReady(true, QString::fromStdWString(L"截图成功,保存地址为: " + filename)); } // 取消置顶窗口 pDm->SetWindowState(hwnd, 9); } else { cout "DM BindWindow failed" endl; emit this->captureWindowReady(false, "绑定窗口异常!"); } pDm->UnBindWindow();}
Add Comment