Skip to content

Comments

CmdPal: Window Walker - reevaluate process type when window process is updated #42317

Merged
michaeljolley merged 3 commits intomicrosoft:mainfrom
jiripolasek:feature/38353-cmdpal-ww-unresponsive-uwp-part-deux
Oct 13, 2025
Merged

CmdPal: Window Walker - reevaluate process type when window process is updated #42317
michaeljolley merged 3 commits intomicrosoft:mainfrom
jiripolasek:feature/38353-cmdpal-ww-unresponsive-uwp-part-deux

Conversation

@jiripolasek
Copy link
Collaborator

Summary of the Pull Request

This PR moves ProcessPackagingInspector.Inspect from the WindowProcess constructor to UpdateProcessInfo, ensuring the process type is correctly re-evaluated when the window’s backing process changes (as with UWP apps hosted in ApplicationFrameHost.exe).

See

private static WindowProcess CreateWindowProcessInstance(IntPtr hWindow)
{
lock (_handlesToProcessCache)
{
if (_handlesToProcessCache.Count > 7000)
{
Debug.Print("Clearing Process Cache because it's size is " + _handlesToProcessCache.Count);
_handlesToProcessCache.Clear();
}
// Add window's process to cache if missing
if (!_handlesToProcessCache.ContainsKey(hWindow))
{
// Get process ID and name
var processId = WindowProcess.GetProcessIDFromWindowHandle(hWindow);
var threadId = WindowProcess.GetThreadIDFromWindowHandle(hWindow);
var processName = WindowProcess.GetProcessNameFromProcessID(processId);
if (processName.Length != 0)
{
_handlesToProcessCache.Add(hWindow, new WindowProcess(processId, threadId, processName));
}
else
{
// For the dwm process we cannot receive the name. This is no problem because the window isn't part of result list.
ExtensionHost.LogMessage(new LogMessage() { Message = $"Invalid process {processId} ({processName}) for window handle {hWindow}." });
_handlesToProcessCache.Add(hWindow, new WindowProcess(0, 0, string.Empty));
}
}
// Correct the process data if the window belongs to a uwp app hosted by 'ApplicationFrameHost.exe'
// (This only works if the window isn't minimized. For minimized windows the required child window isn't assigned.)
if (string.Equals(_handlesToProcessCache[hWindow].Name, "ApplicationFrameHost.exe", StringComparison.OrdinalIgnoreCase))
{
new Task(() =>
{
EnumWindowsProc callbackptr = new EnumWindowsProc((IntPtr hwnd, IntPtr lParam) =>
{
// Every uwp app main window has at least three child windows. Only the one we are interested in has a class starting with "Windows.UI.Core." and is assigned to the real app process.
// (The other ones have a class name that begins with the string "ApplicationFrame".)
if (GetWindowClassName(hwnd).StartsWith("Windows.UI.Core.", StringComparison.OrdinalIgnoreCase))
{
var childProcessId = WindowProcess.GetProcessIDFromWindowHandle(hwnd);
var childThreadId = WindowProcess.GetThreadIDFromWindowHandle(hwnd);
var childProcessName = WindowProcess.GetProcessNameFromProcessID(childProcessId);
// Update process info in cache
_handlesToProcessCache[hWindow].UpdateProcessInfo(childProcessId, childThreadId, childProcessName);
return false;
}
else
{
return true;
}
});
_ = NativeMethods.EnumChildWindows(hWindow, callbackptr, 0);

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

…s hosted in ApplicationFrameHost.exe)

Moves `ProcessPackagingInspector.Inspect` from the `WindowProcess` constructor to `UpdateProcessInfo`, which is already invoked at the correct location.
@jiripolasek
Copy link
Collaborator Author

My apologies for my sloppiness 😞

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

Unrecognized words (4)

dfx
fdx
nullref
worktree

These words are not needed and should be removed DFX Worktree

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:jiripolasek/PowerToys.git repository
on the feature/38353-cmdpal-ww-unresponsive-uwp-part-deux branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/c635c2f3f714eec2fcf27b643a1919b9a811ef2e/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/18446482264/attempts/1' &&
git commit -m 'Update check-spelling metadata'
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

@michaeljolley michaeljolley added the Product-Command Palette Refers to the Command Palette utility label Oct 12, 2025
Copy link
Contributor

@michaeljolley michaeljolley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@michaeljolley michaeljolley merged commit 7c8b302 into microsoft:main Oct 13, 2025
10 checks passed
@jiripolasek jiripolasek mentioned this pull request Oct 14, 2025
mirmirmirr pushed a commit to mirmirmirr/PowerToys that referenced this pull request Nov 9, 2025
…s updated (microsoft#42317)

## Summary of the Pull Request

This PR moves `ProcessPackagingInspector.Inspect` from the
`WindowProcess` constructor to `UpdateProcessInfo`, ensuring the process
type is correctly re-evaluated when the window’s backing process changes
(as with UWP apps hosted in `ApplicationFrameHost.exe`).

See
https://github.com/microsoft/PowerToys/blob/4d47659ff99aee40d7a583fd8b7898a182e641a8/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Components/Window.cs#L295-L350

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: microsoft#38353 
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[0.0.11] Window Walker: (UWP) Applications which are PLM suspended show as "not responding"

2 participants