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

## 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.

<img width="1099" height="611" alt="image"
src="https://github.com/user-attachments/assets/e0fe4c0f-3bef-43f8-a526-d22caf9e484e"
/>


## PR Checklist

- [ ] Closes: N/A
- [x] **Communication:** The UX and behavior were discussed before
implementation
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end-user-facing strings can be localized
- [x] **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.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Muyuan Li (from Dev Box) <muyuanli@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2b3acca3-e49b-4936-8fb9-6f669bd449db
This commit is contained in:
Noraa Junker
2026-08-13 22:27:39 +02:00
committed by GitHub
parent b7891108fa
commit 6c9fb8ce52
10 changed files with 400 additions and 26 deletions

View File

@@ -167,7 +167,7 @@ public:
}
}
virtual bool keep_track_of_pressed_win_key() override { return true; }
virtual UINT milliseconds_win_key_must_be_pressed() override { return 900; }
virtual UINT milliseconds_win_key_must_be_pressed() override { return m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts; }
private:
std::wstring app_name;
@@ -301,6 +301,30 @@ private:
{
Logger::warn("Failed to initialize Shortcut Guide start shortcut");
}
try
{
auto propertiesObject = settingsObject.GetNamedObject(L"properties");
if (propertiesObject.HasKey(L"press_time"))
{
auto jsonDurationObject = propertiesObject.GetNamedObject(L"press_time");
if (jsonDurationObject.HasKey(L"value"))
{
auto pressTime = static_cast<UINT>(jsonDurationObject.GetNamedNumber(L"value"));
if (pressTime < 100)
{
pressTime = 100;
}
else if (pressTime > 5000)
{
pressTime = 5000;
}
m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts = pressTime;
}
}
}
catch (...) { /* Keep defaults */ }
}
else
{