diff --git a/src/modules/Projects/ProjectsSnapshotTool/SnapshotUtils.cpp b/src/modules/Projects/ProjectsSnapshotTool/SnapshotUtils.cpp index 351031963a..3cfc9992f5 100644 --- a/src/modules/Projects/ProjectsSnapshotTool/SnapshotUtils.cpp +++ b/src/modules/Projects/ProjectsSnapshotTool/SnapshotUtils.cpp @@ -12,6 +12,11 @@ namespace SnapshotUtils { + namespace NonLocalizable + { + const std::wstring ApplicationFrameHost = L"ApplicationFrameHost.exe"; + } + class WbemHelper { public: @@ -169,18 +174,37 @@ namespace SnapshotUtils } // filter by app path - std::wstring processPath = get_process_path_waiting_uwp(window); + std::wstring processPath = get_process_path(window); if (processPath.empty() || WindowUtils::IsExcludedByDefault(window, processPath, title)) { + Logger::debug(L"Excluded by default: {}, {}", title, processPath); continue; } DWORD pid{}; GetWindowThreadProcessId(window, &pid); + // fix for the packaged apps that are not caught when minimized, e.g., Settings. + if (processPath.ends_with(NonLocalizable::ApplicationFrameHost)) + { + for (auto otherWindow : windows) + { + DWORD otherPid{}; + GetWindowThreadProcessId(otherWindow, &otherPid); + + // searching for the window with the same title but different PID + if (pid != otherPid && title == WindowUtils::GetWindowTitle(otherWindow)) + { + processPath = get_process_path(otherPid); + break; + } + } + } + auto data = Utils::Apps::GetApp(processPath, installedApps); if (!data.has_value() || data->name.empty()) { + Logger::debug(L"Installed app not found: {}, {}", title, processPath); continue; } diff --git a/src/modules/Projects/projects-common/WindowFilter.h b/src/modules/Projects/projects-common/WindowFilter.h index 391c590dc3..76c60e5621 100644 --- a/src/modules/Projects/projects-common/WindowFilter.h +++ b/src/modules/Projects/projects-common/WindowFilter.h @@ -31,19 +31,6 @@ namespace WindowFilter return false; } - bool isPopup = WindowUtils::HasStyle(style, WS_POPUP); - bool hasThickFrame = WindowUtils::HasStyle(style, WS_THICKFRAME); - bool hasCaption = WindowUtils::HasStyle(style, WS_CAPTION); - bool hasMinimizeMaximizeButtons = WindowUtils::HasStyle(style, WS_MINIMIZEBOX) || WindowUtils::HasStyle(style, WS_MAXIMIZEBOX); - if (isPopup && !(hasThickFrame && (hasCaption || hasMinimizeMaximizeButtons))) - { - // popup windows we want to snap: e.g. Calculator, Telegram - // popup windows we don't want to snap: start menu, notification popup, tray window, etc. - // WS_CAPTION, WS_MINIMIZEBOX, WS_MAXIMIZEBOX are used for filtering out menus, - // e.g., in Edge "Running as admin" menu when creating a new PowerToys issue. - return false; - } - if (!VirtualDesktop::instance().IsWindowOnCurrentDesktop(window)) { return false;