Fix ZoomIt Record hotkey ignoring Alt modifier when Alt is the only modifier key#47388
Merged
Conversation
When Alt is the only modifier in the Record toggle hotkey, XOR-ing it away for the RECORD_WINDOW_HOTKEY results in a zero modifier, causing any unmodified key press to trigger window recording. Fix: Skip registering RECORD_CROP_HOTKEY and RECORD_WINDOW_HOTKEY when the XOR operation would produce zero modifiers (i.e., when the single modifier matches the toggled one). Apply this check in all 4 hotkey registration locations in Zoomit.cpp. Also update ZoomItViewModel.cs to return null for RecordToggleKeyCrop and RecordToggleKeyWindow when the derived hotkey would have no modifier keys, preventing display of an invalid shortcut in settings UI. Agent-Logs-Url: https://github.com/microsoft/PowerToys/sessions/70c535fc-8c23-4415-bbbb-029432a5eeb3 Co-authored-by: MuyuanMS <116717757+MuyuanMS@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ZoomIt record toggle hotkey not capturing Alt modifier
Fix ZoomIt Record hotkey ignoring Alt modifier when Alt is the only modifier key
Apr 29, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a ZoomIt recording hotkey edge case where deriving crop/window recording hotkeys via XOR can produce a modifier-less hotkey (when Alt or Shift is the only modifier), causing bare keypresses to trigger recording. The PR updates both the native ZoomIt hotkey registration and the Settings UI display logic to avoid advertising/creating these unsafe derived shortcuts.
Changes:
- Skip registering derived crop/window record hotkeys when the XOR-derived modifier mask is
0(preventing key-only global hotkeys). - Update Settings UI computed properties to return
nullfor inapplicable derived shortcuts so the UI omits the label instead of showing a bare-key shortcut.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/settings-ui/Settings.UI/ViewModels/ZoomItViewModel.cs | Suppresses display of derived record shortcuts when XOR would produce a modifier-less hotkey. |
| src/modules/ZoomIt/ZoomIt/Zoomit.cpp | Prevents registration of derived record hotkeys when the XOR-derived modifier would be zero. |
- Reword C# comments: clarify null return prevents UI display, not hotkey registration - Extract XOR expressions into named locals (cropMod/windowMod) with explicit != 0 checks across all 4 hotkey registration sites in Zoomit.cpp for readability Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
LegendaryBlair
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
ZoomIt derives three recording hotkeys from one base key via XOR: fullscreen (base), crop (base XOR Shift), window (base XOR Alt). When Alt is the sole modifier,
base XOR Alt = 0, registering a modifier-less hotkey that captures every bare keypress (e.g., pressing5triggers window recording).Zoomit.cpp— 4 hotkey registration sites:RECORD_CROP_HOTKEYregistration behind(g_RecordToggleMod ^ MOD_SHIFT) != 0RECORD_WINDOW_HOTKEYregistration behind(g_RecordToggleMod ^ MOD_ALT) != 0ZoomItViewModel.cs—RecordToggleKeyCrop/RecordToggleKeyWindowcomputed properties:nullwhen the derived hotkey would have no modifier keys, so the Settings UI omits the inapplicable shortcut description rather than displaying a bare-key shortcut.PR Checklist
Detailed Description of the Pull Request / Additional comments
ZoomIt registers crop and window recording variants by XOR-ing the base modifier with
MOD_SHIFTandMOD_ALTrespectively. This design breaks when the base modifier equals the XOR target — the result is0, andRegisterHotKeywith no modifiers intercepts every bare keypress of that key system-wide.The fix is symmetric across all 4 registration sites (standalone
registerHotkey()inRegisterAllHotkeys, the legacy dialog OK path, and twoWM_CREATE-adjacent paths): skip the derived hotkey registration when the computed modifier is zero. The Settings UI ViewModel mirrors this logic by returningnullfor the affected computed properties, causing the converter to emit an empty string instead of a modifier-less shortcut label.Validation Steps Performed
RegisterHotKeycall sites inZoomit.cppHotkeySettingsToLocalizedStringConverterreturnsstring.Emptyfornullinput — no display regression in Settings UICtrl+5hotkey is unaffected (MOD_CONTROL ^ MOD_ALT = MOD_CONTROL | MOD_ALT ≠ 0)