int MarkupMainFrame::waitKey( int delay ) { int key = cv::waitKey(delay); if (key == kNoKeyPressed) return key; HWND hWnd = GetActiveWindow(); char lpBuff[MAX_PATH] = {0}; int ret = GetWindowText(hWnd, lpBuff, MAX_PATH); std::string strWindowTitle(lpBuff); std::string strAGM = "type=AGM_"; int nf = strWindowTitle.find(strAGM); if (std::string::npos != nf) { this->pGeoMapEditor->pressed_keys.push_back(key); this->pGeoMapEditor->processKeys(); if (key == kTab || key == kBackSpace) { key = kNoKeyPressed; } } // select active window; //... // if none -- ask others //... return key;//cv::waitKey(delay); }
int Run(LPTSTR lpstrCmdLine = NULL, int nCmdShow = SW_SHOWDEFAULT) { CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); wstring strConfigFile(L""); wstring strWindowTitle(L""); vector<wstring> startupTabs; vector<wstring> startupDirs; vector<wstring> startupCmds; int nMultiStartSleep = 0; wstring strDbgCmdLine(L""); ParseCommandLine( lpstrCmdLine, strConfigFile, strWindowTitle, startupTabs, startupDirs, startupCmds, nMultiStartSleep, strDbgCmdLine); if (strConfigFile.length() == 0) { strConfigFile = wstring(L"console.xml"); // strConfigFile = Helpers::GetModulePath(NULL) + wstring(L"console.xml"); // strConfigFile = wstring(::_wgetenv(L"APPDATA")) + wstring(L"\\Console\\console.xml"); } if (!g_settingsHandler->LoadSettings(Helpers::ExpandEnvironmentStrings(strConfigFile))) { //TODO: error handling return 1; } // create main window NoTaskbarParent noTaskbarParent; MainFrame wndMain(strWindowTitle, startupTabs, startupDirs, startupCmds, nMultiStartSleep, strDbgCmdLine); if (!g_settingsHandler->GetAppearanceSettings().stylesSettings.bTaskbarButton) { noTaskbarParent.Create(NULL); } if(wndMain.CreateEx(noTaskbarParent.m_hWnd) == NULL) { ATLTRACE(_T("Main window creation failed!\n")); return 1; } wndMain.ShowWindow(nCmdShow); int nRet = theLoop.Run(); if (noTaskbarParent.m_hWnd != NULL) noTaskbarParent.DestroyWindow(); _Module.RemoveMessageLoop(); return nRet; }
int main( char *pszArg[] ) { ShowWindow(GetConsoleWindow(), SW_HIDE); SetProcessDPIAware(); std::string strWindowTitle( "", 0x40 ); strWindowTitle = "Guild Wars 2"; Overlay::IOverlay *pOverlay = new Overlay::CD3D9Overlay( ); pOverlay->GetSurface( )->PrepareFont( "Default", "Arial", 20, FW_BOLD, 0, 0, FALSE ); pOverlay->GetSurface()->PrepareFont("Headline", "Arial", 25, FW_BOLD, 0, 0, FALSE); if( pOverlay->Create( strWindowTitle ) ) { auto WaterMarkFn = []( Overlay::IOverlay *pOverlay, std::shared_ptr< Overlay::ISurface > pSurface ) { //Move overlay if window is moved /*for (int i = 1; i <= barWidth; i++) { for (int j = 1; j <= barHeight; j++) { int x = i; int y = j; int col = createRGBA(posR(x, y), posG(x, y), posB(x, y), 255); pSurface->Rect(500 + i, 800 + j, 1, 1, col); } }*/ pOverlay->ScaleOverlayWindow(); processInput(pSurface); displayPercentualHP(pSurface); if (showMenu) { displayMenu(pSurface); } /**pSurface->Rect(800, 90, 100, 50, barColor); POINT p; GetPhysicalCursorPos(&p); HWND window = GetForegroundWindow(); ScreenToClient(window, &p); std::stringstream s2; s2 << std::fixed << std::setprecision(1) << p.x << " | " << p.y; std::string col = s2.str() + "P"; static char cola[1024]; strncpy_s(cola, col.c_str(), sizeof(cola)); pSurface->String(500, 90, "Default", createRGBA(0, 255, 0, 255), cola); strncpy_s(cola, std::to_string(barPosX).c_str(), sizeof(cola)); pSurface->String(500, 120, "Default", createRGBA(0, 255, 0, 255), cola); strncpy_s(cola, std::to_string(barPosY).c_str(), sizeof(cola)); pSurface->String(500, 150, "Default", createRGBA(0, 255, 0, 255), cola); strncpy_s(cola, std::to_string(barWidth).c_str(), sizeof(cola)); pSurface->String(500, 180, "Default", createRGBA(0, 255, 0, 255), cola); strncpy_s(cola, std::to_string(barHeight).c_str(), sizeof(cola)); pSurface->String(500, 210, "Default", createRGBA(0, 255, 0, 255), cola); */ }; pOverlay->AddToCallback( WaterMarkFn ); while (pOverlay->Render()) { } }else { } pOverlay->Shutdown(); delete pOverlay; return 0; }
int Run(LPTSTR lpstrCmdLine = NULL, int nCmdShow = SW_SHOWDEFAULT) { // vds: >> HANDLE hOneInstanceMutex = CreateMutex(NULL, FALSE, _T("ConsoleOnInstanceMutex")); DWORD oneInstanceResult = GetLastError(); bool bOneInstance = oneInstanceResult == ERROR_ALREADY_EXISTS; // vds: HWND hPrevConsole = FindWindow(MainFrame::GetWndClassInfo().m_wc.lpszClassName, NULL); // vds: << CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); wstring strConfigFile(L""); wstring strWindowTitle(L""); vector<wstring> startupTabs; vector<wstring> startupDirs; vector<wstring> startupCmds; vector<wstring> postedCmds; // vds: posted commands vector<bool> reusePreviousTabs; // vds: sessions int nMultiStartSleep = 0; wstring strDbgCmdLine(L""); WORD iFlags = 0; // vds ParseCommandLine( lpstrCmdLine, strConfigFile, strWindowTitle, startupTabs, startupDirs, startupCmds, postedCmds, nMultiStartSleep, strDbgCmdLine, iFlags); // vds if (strConfigFile.length() == 0) { strConfigFile = wstring(L"console.xml"); // vds // strConfigFile = wstring(L"%APPDATA%\Console\console.xml"); // strConfigFile = Helpers::GetModulePath(NULL) + wstring(L"console.xml"); // strConfigFile = wstring(::_wgetenv(L"APPDATA")) + wstring(L"\\Console\\console.xml"); // vds } if (!g_settingsHandler->LoadSettings(Helpers::ExpandEnvironmentStrings(strConfigFile))) { //TODO: error handling return -1; } // vds: >> if (g_settingsHandler->GetBehaviorSettings().oneInstanceSettings.bAllowMultipleInstances && !(iFlags & CLF_REUSE_PREV_INSTANCE)) bOneInstance = false; if (iFlags & CLF_FORCE_NEW_INSTANCE) bOneInstance = false; // vds: << // vds: sessions >> bool reuseTab = g_settingsHandler->GetBehaviorSettings().oneInstanceSettings.bReuseTab; while (reusePreviousTabs.size() < startupTabs.size()) { reusePreviousTabs.push_back(reuseTab); } // vds: sessions << // vds: sessions >> if (!bOneInstance) { SessionsSettings& sessionsSettings = g_settingsHandler->GetSessionsSettings(); if (sessionsSettings.bRestoreTabs) { for (unsigned int j = 0; j < sessionsSettings.sessionDataVector.size(); ++j) { shared_ptr<SessionData> sessionData = sessionsSettings.sessionDataVector[j]; startupTabs.insert(startupTabs.begin() + j, sessionData->strTabTitle); startupDirs.insert(startupDirs.begin() + j, sessionData->strWorkingDir); startupCmds.insert(startupCmds.begin() + j, L""); postedCmds.insert(postedCmds.begin() + j, L""); reusePreviousTabs.insert(reusePreviousTabs.begin() + j, false); } } } // vds: sessions << // create main window NoTaskbarParent noTaskbarParent; MainFrame wndMain(strWindowTitle, startupTabs, startupDirs, startupCmds, postedCmds, reusePreviousTabs, nMultiStartSleep, bOneInstance, strDbgCmdLine); // vds: if (!g_settingsHandler->GetAppearanceSettings().stylesSettings.bTaskbarButton && !bOneInstance) // vds: { noTaskbarParent.Create(NULL); } if (wndMain.CreateEx(noTaskbarParent.m_hWnd) == NULL) { ATLTRACE(_T("Main window creation failed!\n")); return 1; } // vds: >> // vds: This variable has to be in the scope of the theLoop.Run() call otherwise the message is destroyed before it arrive to destination. wstring rebuildCommandLine; if (!bOneInstance) { wndMain.ShowWindow(nCmdShow); } else { // Give 3 seconds to exchange the DDE messages. wndMain.SetTimer(TIMER_TIMEOUT, 3000, NULL); rebuildCommandLine = BuildCommandLine( strConfigFile, strWindowTitle, startupTabs, startupDirs, startupCmds, postedCmds, nMultiStartSleep, strDbgCmdLine, iFlags); #ifdef USE_COPYDATA_MSG // Search for running instance of console if (hPrevConsole) { COPYDATASTRUCT stCopyData; stCopyData.dwData = eEC_NewTab; stCopyData.cbData = (rebuildCommandLine.size() + 1) * sizeof(wchar_t); stCopyData.lpData = reinterpret_cast<void*>(const_cast<wchar_t*>(rebuildCommandLine.c_str())); SendMessage(hPrevConsole, WM_COPYDATA, 0, (LPARAM)(LPVOID)&stCopyData); } #else ::PostMessage(wndMain.m_hWnd, WM_SEND_DDE_COMMAND, reinterpret_cast<WPARAM>(hPrevConsole), reinterpret_cast<LPARAM>(rebuildCommandLine.c_str())); #endif } // vds: << int nRet = theLoop.Run(); if (noTaskbarParent.m_hWnd != NULL) noTaskbarParent.DestroyWindow(); _Module.RemoveMessageLoop(); // vds: >> if (hOneInstanceMutex) { CloseHandle(hOneInstanceMutex); hOneInstanceMutex = NULL; } // vds: << return nRet; }