diff --git a/ODTKRA/Main.cpp b/ODTKRA/Main.cpp index 35ee640..97dfe17 100644 --- a/ODTKRA/Main.cpp +++ b/ODTKRA/Main.cpp @@ -140,6 +140,8 @@ void start_process(std::string path) { ShellExecute(NULL, L"open", (LPCWSTR)std::wstring(tempstr.begin(), tempstr.end()).c_str(), NULL, NULL, SW_SHOWDEFAULT); HWND hWindowHandle; + Sleep(500); + //wait for window to load std::cout << "Waiting for window to load" << std::endl; while ((hWindowHandle = get_winhandle((LPCWSTR)L"Oculus Debug Tool")) == NULL) { @@ -155,7 +157,8 @@ void start_process(std::string path) { std::cout << "Waiting for window to be focused" << std::endl; while (GetForegroundWindow() != hWindowHandle) { - SwitchToThisWindow(hWindowHandle, true); + if (doKillODTThread) return; + SetForegroundWindow(hWindowHandle); Sleep(50); } std::cout << "ODT window focused!" << std::endl; @@ -192,11 +195,16 @@ void parse_args(int argc, char* argv[]) { } } +bool threadRunning; + void doToggle() { + threadRunning = true; start_process(ODTPath); if (!doKillODTThread) Sleep(100); killODT(0); + + threadRunning = false; } int main(int argc, char* argv[]) { @@ -236,8 +244,10 @@ int main(int argc, char* argv[]) { if (tk - lastIdle < seconds(15)) { - doKillODTThread = true; - refresh_loop = tk; + if (threadRunning) { + doKillODTThread = true; + refresh_loop = tk; + } } else {