Skip to content

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

Open
yeelam-gordon wants to merge 1 commit intomainfrom
user/yeelam/FixAutoCopyIssue
Open

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

Conversation

@yeelam-gordon
Copy link
Copy Markdown
Contributor

Summary

Fixes #46485

AdvancedPaste's auto-copy feature fails on Electron/Chromium-based apps (e.g. Microsoft Teams, VS Code, browsers) because WM_COPY is delivered successfully but silently ignored by these apps.

Problem

The auto-copy code sends WM_COPY via SendMessageTimeout. For standard Win32 controls this works, but Electron apps accept the message delivery without actually copying to clipboard. The code treated successful delivery as success and never fell back to SendInput Ctrl+C.

Changes

src/modules/AdvancedPaste/AdvancedPasteModuleInterface/dllmain.cpp:

  • Changed retry logic: Each attempt now tries both WM_COPY and SendInput Ctrl+C. If WM_COPY is delivered but clipboard is unchanged, it falls through to Ctrl+C instead of giving up.
  • Extracted poll_clipboard_sequence() helper: Reusable clipboard polling logic (checks GetClipboardSequenceNumber over N polls with configurable delay).
  • Extracted send_ctrl_c_input() helper: Sends Ctrl+C via SendInput with CENTRALIZED_KEYBOARD_HOOK_DONT_TRIGGER_FLAG.
  • Improved logging: Each strategy logs clearly whether it succeeded or fell through, making future debugging easier.

Validation

  • Manual testing with Microsoft Teams (Electron): auto-copy now works for selected text
  • Standard Win32 apps (Notepad, etc.): WM_COPY still works on first try, no regression
  • No new warnings or errors in build

…eams)

WM_COPY message is delivered successfully to Electron apps but silently
ignored, so the clipboard never changes. The old code treated WM_COPY
delivery as success and never fell back to SendInput Ctrl+C.

Now each attempt tries both strategies: WM_COPY first (fast path for
standard Win32 controls), then Ctrl+C via SendInput if the clipboard
sequence didn't change (needed for Electron/Chromium/browser apps).

Also extracted send_ctrl_c_input() and poll_clipboard_sequence() helpers
for clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AdvancedPaste] Auto-copy selection fails on Electron/Chromium apps (e.g. Microsoft Teams)

1 participant