How does the Windows Task Switcher populate the list of windows?

  alt-tab, user32, windows

I am writing a Windows 10 C#/WPF application using User32.dll to list, manage and switch between windows.

I have come across an application (Microsoft Teams Room) where I am unable to find the IntPtr handle for either the main window or the video conference window. The windows both show in the regular ALT-TAB task switcher as "Microsoft Teams Room" and show the correct thumbnail. The ALT-TAB behaviour is correct and happily brings the windows to the front and puts them in focus.

I have written the following console application to try and brute force discovery of the window handles:

        foreach (IntPtr window in User32Utils.GetAllWindows())
            string title = User32Utils.GetWindowText(window);
            title = title == null ? "NULL" : string.Format(""{0}"", title);

            string handleHex = window.ToInt64().ToString("X8");

            Console.WriteLine("Switching to window {0}-{1}", handleHex, title);
            User32Utils.LockForegroundWindow(false); // Possibly not needed?
            User32Utils.SwitchToThisWindow(handle, true);
            User32Utils.SetForegroundWindow(handle); // Possibly not needed?


It cycles through the windows:

Switching to window 0002004A-""
Switching to window 00020301-"Task Host Window"
Switching to window 00010304-""

And I can visually see it switching between windows, but it never switches to either of the Microsoft Teams Room windows.

So my questions are:

  1. How does the Windows Task Switcher determine which windows are pertinent to the user?
  2. Where does the Windows Task Switcher get the window titles from? They don’t always match the User32 GetWindowText result.
  3. What is the correct method of switching to a given window to match the behaviour of the task switcher?
  4. It seems like these particular windows aren’t present in the User32 EnumWindows or EnumChildWindows result sets. Is it possible that the application is somehow registering non-traditional "windows" against the task switcher?

Source: Windows Questions