You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix AdvancedPaste auto-copy failing on Electron/Chromium apps (#46486)
## 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
- [x] Manual testing with Microsoft Teams (Electron): auto-copy now
works for selected text
- [x] Standard Win32 apps (Notepad, etc.): `WM_COPY` still works on
first try, no regression
- [x] No new warnings or errors in build
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
// Prevent Start Menu from activating after Win key release/restore
596
+
INPUT dummyEvent = {};
597
+
dummyEvent.type = INPUT_KEYBOARD;
598
+
dummyEvent.ki.wVk = 0xFF;
599
+
dummyEvent.ki.dwFlags = KEYEVENTF_KEYUP;
600
+
inputs.push_back(dummyEvent);
601
+
602
+
auto uSent = SendInput(static_cast<UINT>(inputs.size()), inputs.data(), sizeof(INPUT));
603
+
if (uSent != inputs.size())
604
+
{
605
+
DWORD errorCode = GetLastError();
606
+
auto errorMessage = get_last_error_message(errorCode);
607
+
Logger::error(L"SendInput failed for Ctrl+C. Expected to send {} inputs and sent only {}. {}", inputs.size(), uSent, errorMessage.has_value() ? errorMessage.value() : L"");
auto uSent = SendInput(static_cast<UINT>(inputs.size()), inputs.data(), sizeof(INPUT));
573
-
if (uSent != inputs.size())
574
-
{
575
-
DWORD errorCode = GetLastError();
576
-
auto errorMessage = get_last_error_message(errorCode);
577
-
Logger::error(L"SendInput failed for Ctrl+C. Expected to send {} inputs and sent only {}. {}", inputs.size(), uSent, errorMessage.has_value() ? errorMessage.value() : L"");
0 commit comments