Skip to content

[Shortcut Guide] Add Windows key hold activation options - #49661

Open
noraa-junker wants to merge 7 commits into
mainfrom
dev/noraa-junker/add-keyhold-options-sg
Open

[Shortcut Guide] Add Windows key hold activation options #49661
noraa-junker wants to merge 7 commits into
mainfrom
dev/noraa-junker/add-keyhold-options-sg

Conversation

@noraa-junker

Copy link
Copy Markdown
Collaborator

Summary of the Pull Request

Adds configurable Windows-key hold activation to Shortcut Guide while keeping the regular activation shortcut independent.

Users can choose to disable Windows-key activation, show taskbar indicators, or open the full Shortcut Guide. Full-guide mode also supports a configurable hold duration and optional close-on-release behavior.

image

PR Checklist

  • Closes: N/A
  • Communication: The UX and behavior were discussed before implementation
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Not applicable
  • Documentation updated: Not applicable

Detailed Description of the Pull Request / Additional comments

  • Adds Off, taskbar-indicator, and full-guide Windows-key actions to Settings.
  • Adds a 100–5,000 ms hold-duration setting and a full-guide close-on-release option.
  • Handles left and right Windows keys and suppresses Start after an activated hold.
  • Routes Windows-key holds through a dedicated event so custom activation shortcuts remain independent.
  • Clears previous pressed-key registrations before refreshing them to prevent duplicate long-press callbacks.
  • Preserves compatibility with the existing press_time setting and documents the new options.

Validation Steps Performed

  • Built the affected ARM64 Debug Settings, Runner, Shortcut Guide module-interface, and Shortcut Guide UI projects.
  • ShortcutGuide.UnitTests: 7/7 passed.
  • Targeted Settings tests: 12/12 passed.
  • Manually verified Off, taskbar-indicator, full-guide close-on-release, and full-guide persistent modes.
  • Verified configured hold thresholds, both Windows keys, Start suppression, and regular-shortcut independence.
  • Validated the final Settings XAML layout in the running Settings app.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Not ready to approve

There are confirmed behavior gaps/bugs in the Shortcut Guide UI/module interface around Windows-key handling and settings enforcement (notably RWIN detection and Runner-level disablement).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds configurable “hold Windows key” activation behaviors to Shortcut Guide, wiring new settings through the Settings UI, settings model, module interface, UI runtime behavior, tests, and documentation.

Changes:

  • Introduces a new Windows-key hold action setting (Off / taskbar indicators / full guide), plus hold-duration and close-on-release options.
  • Plumbs the new settings through the Settings UI (ViewModel + XAML + localized strings) and updates module/UI logic to honor them.
  • Updates unit tests and developer/DSC documentation to cover the new settings and defaults.
File summaries
File Description
src/settings-ui/Settings.UI/ViewModels/ShortcutGuideViewModel.cs Adds ViewModel properties for Windows-key action, hold duration, and close-on-release with normalization/clamping.
src/settings-ui/Settings.UI/Strings/en-us/Resources.resw Adds localized strings for the new settings UI.
src/settings-ui/Settings.UI/SettingsXAML/Views/ShortcutGuidePage.xaml Adds new settings expander UI (ComboBox + NumberBox + CheckBox) for Windows-key hold behavior.
src/settings-ui/Settings.UI.UnitTests/ViewModelTests/ShortcutGuide.cs Extends tests for defaults, normalization, persistence, and back-compat expectations.
src/settings-ui/Settings.UI.Library/ShortcutGuideWindowsKeyAction.cs Adds enum representing Windows-key hold action.
src/settings-ui/Settings.UI.Library/ShortcutGuideProperties.cs Adds persisted properties + constants for defaults and press-time bounds.
src/modules/ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp Uses configured press_time for Runner’s long-press threshold instead of a constant.
src/modules/ShortcutGuide/ShortcutGuide.Ui/ShortcutGuideXAML/App.xaml.cs Updates runtime behavior to support Off / taskbar indicators / full guide + close-on-release.
doc/dsc/modules/ShortcutGuide.md Documents new DSC properties and updated defaults/ranges.
doc/devdocs/modules/shortcut_guide.md Updates end-user/developer documentation for the new activation behaviors.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 4
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread src/modules/ShortcutGuide/ShortcutGuide.Ui/ShortcutGuideXAML/App.xaml.cs Outdated
Comment thread src/modules/ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp Outdated
Comment thread src/modules/ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp
noraa-junker and others added 2 commits August 4, 2026 16:59
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@niels9001 niels9001 added 0.101 Product-Shortcut Guide Refers to the Shortcut Guide PowerToy labels Aug 4, 2026
@niels9001
niels9001 requested a lite review from Copilot August 4, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Not ready to approve

The “Off” Windows-key action is not fully enforced at the Runner/module-interface registration level, so Win-key long-press callbacks can still fire and launch/signaled behavior can still occur.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (3)

src/modules/ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp:170

  • The new “WindowsKeyAction = Off” setting doesn’t actually disable Windows-key long-press activation at the Runner/hook level: this module still returns true from keep_track_of_pressed_win_key(), so Runner will continue registering VK_LWIN/VK_RWIN pressed-key timers that invoke OnHotkeyEx(), which can still start the ShortcutGuide process and signal the trigger event. This contradicts the PR’s stated ability to disable Windows-key activation and also adds avoidable background work when users choose Off.

Consider parsing win_key_action here and returning false from keep_track_of_pressed_win_key() when it is Off (and/or early-returning in OnHotkeyEx() for win-key-triggered launches) so Runner doesn’t register or fire long-press callbacks when disabled.

    virtual bool keep_track_of_pressed_win_key() override { return true; }
    virtual UINT milliseconds_win_key_must_be_pressed() override { return m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts; }

src/modules/ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp:306

  • The try statement is mis-indented compared to the surrounding block, which makes this section harder to read and looks like an accidental formatting regression (likely should be clang-formatted).
try
            {

src/modules/ShortcutGuide/ShortcutGuide.Ui/ShortcutGuideXAML/App.xaml.cs:207

  • These declarations lost their indentation inside the dispatched lambda, which hurts readability and is inconsistent with the surrounding code formatting.
const int VK_LWIN = 0x5B;
const int VK_RWIN = 0x5C;
bool winKeyDown = ((NativeMethods.GetAsyncKeyState(VK_LWIN) & 0x8000) != 0) ||
                 ((NativeMethods.GetAsyncKeyState(VK_RWIN) & 0x8000) != 0);
  • Files reviewed: 10/10 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@noraa-junker

Copy link
Copy Markdown
Collaborator Author

No this hasn't happened once while testing and neither has this happened once with the old Shortcut Guide which used the same system.

@noraa-junker

Copy link
Copy Markdown
Collaborator Author

@copilot
Fix the identation in this file:

src\modules\ShortcutGuide\ShortcutGuide.Ui\ShortcutGuideXAML\App.xaml.cs(208,1): Error SA1137: Elements should have the same indentation (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1137.md)
``

Copilot AI and others added 2 commits August 4, 2026 22:15
Co-authored-by: noraa-junker <58633848+noraa-junker@users.noreply.github.com>
Co-authored-by: noraa-junker <58633848+noraa-junker@users.noreply.github.com>

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@copilot
Fix the identation in this file:

...

Fixed in 2334fbd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.101 Product-Shortcut Guide Refers to the Shortcut Guide PowerToy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants