AcManager.Controls.Dialogs.PromptCodeFromBrowser.GetOpenWindows C# (CSharp) Method

GetOpenWindows() public static method

Returns a dictionary that contains the handle and title of all the open windows.
public static GetOpenWindows ( ) : string>.IDictionary
return string>.IDictionary
        public static IDictionary<IntPtr, string> GetOpenWindows() {
            var shellWindow = User32.GetShellWindow();
            var windows = new Dictionary<IntPtr, string>();

            User32.EnumWindows(delegate (IntPtr hWnd, int lParam) {
                if (hWnd == shellWindow) return true;
                if (!User32.IsWindowVisible(hWnd)) return true;

                var length = User32.GetWindowTextLength(hWnd);
                if (length == 0) return true;

                var builder = new StringBuilder(length);
                User32.GetWindowText(hWnd, builder, length + 1);

                windows[hWnd] = builder.ToString();
                return true;
            }, 0);

            return windows;
        }
    }
PromptCodeFromBrowser