Skip to content

Fix AdvancedPaste auto-copy failing on Electron/Chromium apps#46486

Merged
yeelam-gordon merged 1 commit intomainfrom
user/yeelam/FixAutoCopyIssue
Apr 16, 2026
Merged

Fix AdvancedPaste auto-copy failing on Electron/Chromium apps#46486
yeelam-gordon merged 1 commit intomainfrom
user/yeelam/FixAutoCopyIssue

Conversation

@yeelam-gordon
Copy link
Copy Markdown
Contributor

@yeelam-gordon yeelam-gordon commented Mar 25, 2026

Summary

Fixes AdvancedPaste custom action auto-copy failing on Electron/Chromium apps (e.g. Teams, VS Code, browsers).

Problem

The Ctrl+C fallback in \send_copy_selection()\ injected keystrokes without first releasing modifier keys held from the hotkey combination. Target apps received e.g. \Win+Shift+Ctrl+C\ instead of \Ctrl+C, so the copy never triggered.

Changes

  • Release modifier keys before Ctrl+C and restore them after, matching the existing \ ry_to_paste_as_plain_text()\ pattern for Ctrl+V
  • Extract helpers \send_ctrl_c_input()\ and \poll_clipboard_sequence()\ from inline code
  • Add warn-level logging on failure paths for customer diagnostics
  • Check WM_COPY result — verify clipboard actually changed before declaring success

Validation

  • Tested auto-copy custom action on Electron apps (Teams) — now works
  • Confirmed warn-level logs appear on failure for diagnostics
  • No regressions in standard Win32 app copy behavior

@yeelam-gordon yeelam-gordon requested a review from Copilot April 15, 2026 12:42
@yeelam-gordon yeelam-gordon added this to the PowerToys 0.99 milestone Apr 15, 2026
@yeelam-gordon
Copy link
Copy Markdown
Contributor Author

/azp run

@yeelam-gordon yeelam-gordon enabled auto-merge (squash) April 15, 2026 12:46
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

The Ctrl+C fallback in send_copy_selection() was injecting keystrokes
without first releasing modifier keys held from the hotkey combination.
Target apps received e.g. Win+Shift+Ctrl+C instead of Ctrl+C, which
doesn't trigger a copy.

Changes:
- Release all modifier keys before Ctrl+C and restore them after,
  matching the existing try_to_paste_as_plain_text() pattern
- Extract send_ctrl_c_input() and poll_clipboard_sequence() helpers
  from inline code for clarity
- Increase clipboard polling window from 150ms to 500ms for slower
  Chromium/Electron clipboard updates
- Add warn-level logging on failure paths for customer diagnostics
- Check WM_COPY actually changed the clipboard before declaring success

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@yeelam-gordon yeelam-gordon force-pushed the user/yeelam/FixAutoCopyIssue branch from 5f3289c to bf34514 Compare April 16, 2026 00:54
@yeelam-gordon yeelam-gordon merged commit befb5c6 into main Apr 16, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants