I'm trying to create a Windows Taskbar replacement in C# because I'm disgusted by the Win10 one. A problem I'm having though is that I can't get a correct enumeration of the windows.
Basically the code down below doesn't give me any UWP windows. Also it gets windows from other virtual desktops. How can I get a list of handles to windows that is equal to or similar to the list of windows in the taskbar?
Here is the current code I'm using (HWND == System.IntPtr and BOOL = System.Boolean):
static HWND GetLastActivePopupOfWindow(HWND root)
{
HWND lastPopup = GetLastActivePopup(root);
if (IsWindowVisible(lastPopup))
return lastPopup;
if (lastPopup == root)
return HWND.Zero;
return GetLastActivePopupOfWindow(lastPopup);
}
static BOOL IsAltTabWindow(HWND hwnd)
{
if (!IsWindowVisible(hwnd))
return false;
HWND root = GetAncestor(hwnd, 3);
if (GetLastActivePopupOfWindow(root) == hwnd)
{
Window wi = new Window(hwnd);
MessageBox.Show(wi.ClassName + "\r\n" + wi.Title);
if (wi.ClassName == "Shell_TrayWnd" || //Windows taskbar
wi.ClassName == "WorkerW" ||
wi.ClassName == "ProgMan" ||
wi.ClassName == "ThumbnailDeviceHelperWnd" ||
wi.ClassName == "Windows.UI.Core.CoreWindow" || //Empty UWP apps
wi.ClassName == "DV2ControlHost" || //Windows startmenu, if open
(wi.ClassName == "Button" && wi.Title == "Start") || //Windows startmenu-button.
wi.ClassName == "MsgrIMEWindowClass" || //Live messenger's notifybox i think
wi.ClassName == "SysShadow" || //Live messenger's shadow-hack
wi.ClassName.StartsWith("WMP9MediaBarFlyout") ||
wi.Title.Length == 0) //WMP's "now playing" taskbar-toolbar
return false;
return true;
}
return false;
}