diff --git a/advanced-scene-switcher-win.cpp b/advanced-scene-switcher-win.cpp index 31d2bf6f..8ffa1d7e 100644 --- a/advanced-scene-switcher-win.cpp +++ b/advanced-scene-switcher-win.cpp @@ -61,7 +61,16 @@ void GetWindowList(vector& windows) void GetCurrentWindowTitle(string& title) { HWND window = GetForegroundWindow(); - //DWORD id; + DWORD id; + GetWindowThreadProcessId(window, &id); + /*GetWindowText will freeze if the control it is reading was created in another thread. + It does not directly read the control.Instead, + it waits for the thread that created the control to process a WM_GETTEXT message. + So if that thread is frozen in a WaitFor... call you have a deadlock.*/ + if (id == GetCurrentProcessId()) { + title = ""; + return; + } GetWindowTitle(window, title); } @@ -155,4 +164,4 @@ int getTime() int secondsSinceLastInput() { return (getTime() - getLastInputTime()) / 1000; -} \ No newline at end of file +}