microsoft / microsoft/microsoft-ui-xaml

How can I intercept WM_APPCOMMAND in WinUI 3 for custom navigation?

Open
#10,711 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

Hello,

I’m working on implementing custom navigation handling in a WinUI 3 app, and I’d like to handle WM_APPCOMMAND messages—specifically for browser navigation keys (e.g., back, forward, home).

However, I’ve noticed that while WM_APPCOMMAND with some commands like APPCOMMAND_BROWSER_HOME make it to my window (so I can handle them in a custom WndProc), others—such as APPCOMMAND_BROWSER_BACKWARD—never reach my handler. It seems like these messages are being filtered or intercepted by the system before I can process them.

Is there any way to gain access to these navigation commands in WinUI 3? I’m hoping to avoid resorting to global keyboard hooks or other invasive solutions if possible.

Has anyone found a workaround, or is this interception by design in the WinUI 3 framework?

Thanks in advance for any pointers!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing WM_APPCOMMAND handling in a WinUI 3 window using the custom WndProc described in the issue, comparing APPCOMMAND_BROWSER_HOME with APPCOMMAND_BROWSER_BACKWARD. Trace where the differing messages are filtered or intercepted; done requires identifying a supported access path or documenting that the behavior is by design.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.