public void GetChatWindows() { ChatWindows.Clear(); foreach (int processThreadId in ProcessThreads) { EnumThreadWindows(processThreadId, new EnumThreadWindowsCallback((hwnd, lparam) => { StringBuilder className = new StringBuilder(260); GetClassName(hwnd, className, 260); if (className.ToString() == "SDL_app") { StringBuilder windowText = new StringBuilder(260); GetWindowText(hwnd, windowText, 260); if (windowText.ToString() != "Friends List") { ChatWindow window = ChatWindow.FromHandle(hwnd, windowText.ToString()); ChatWindows.Add(window); Console.WriteLine("Detected chat window: " + windowText.ToString()); } } return(true); }), IntPtr.Zero); } }