Repository navigation
Description
Describe the bug
As discussed in ticket #3395, the scripting API’s copy() function can be called without arguments, but may throw an exception. Although the concrete situations where such an exception is expected are not specified, this visibly happens when it shouldn't, when a custom command calling copy() is launched via a keyboard shortcut using the ⊞ Win modifier. I assume this is specific to Microsoft Windows, but both PCs on which I tested (which both run CopyQ on Windows 11 25H2) reproduce the vast majority of time, apparently with any such shortcut, including:
- ⊞ Win+Y
- ⊞ Win+Alt+Z
- ⊞ Win+F10
This notably affects the Replace in Selection command.
As pointed out by @pbodnar, this may not occur if the shortcut (which seems to include the time the Windows key is held) is typed fast enough, but this should be trivial to reproduce on an affected OS.
To Reproduce
Simply calling the dummy command which beefeater7 provides in the body of ticket #1440 suffices to reproduce:
- Change the shortcut to ⊞ Win+Y
- Select this text
- Type ⊞ Win+Y, but not too fast
Expected behavior
The custom command succeeds, copying the selection
Actual behavior
3 notifications display, including one which reports a “Failed to copy to clipboard!” exception.
Several messages are logged (oddly, merely at Note level):
[2026-01-26 12:56:21.539] Note <Server-25444>: Exception in command "Replace in Selection testcase": ScriptError: Failed to copy to clipboard!
[2026-01-26 12:56:21.539] Note <Server-25444>:
[2026-01-26 12:56:21.539] Note <Server-25444>: --- backtrace ---
[2026-01-26 12:56:21.539] Note <Server-25444>: f@:1
[2026-01-26 12:56:21.539] Note <Server-25444>: %entry@eval code:2
[2026-01-26 12:56:21.539] Note <Server-25444>: f@:1
[2026-01-26 12:56:21.539] Note <Server-25444>: eval:
[2026-01-26 12:56:21.539] Note <Server-25444>: copy()
[2026-01-26 12:56:21.539] Note <Server-25444>:
[2026-01-26 12:56:21.539] Note <Server-25444>: eval
[2026-01-26 12:56:21.539] Note <Server-25444>: --- end backtrace ---
[2026-01-26 12:56:21.546] Note <Server-25444>: Command “Replace in Selection testcase”
[2026-01-26 12:56:21.546] Note <Server-25444>: Exit code: 4
[2026-01-26 12:56:21.546] Note <Server-25444>: 1. copyq:
[2026-01-26 12:56:21.546] Note <Server-25444>: 2. copy()
Version, OS and Environment
CopyQ Clipboard Manager 13.0.0
Qt: 6.8.3
KNotifications: 6.12.0
Compiler: MSVC
Arch: x86_64-little_endian-llp64
OS: Windows 11 Version 25H2
- Windows installer
This reportedly goes back to at least July 2020.
Additional context
Credits to @pbodnar for reporting a specific case of this (in ticket #1435)
Activity
[-]`copy()` (without arguments) triggers “Failed to copy to clipboard!” exception when custom command called with shortcut using <kbd>⊞ Win</kbd> as modifier[/-][+]`copy()` (without arguments) triggers “Failed to copy to clipboard!” exception when custom command called with shortcut using ⊞ Win as modifier[/+][-]`copy()` (without arguments) triggers “Failed to copy to clipboard!” exception when custom command called with shortcut using ⊞ Win as modifier[/-][+]`copy()` throws “Failed to copy to clipboard!” if triggered using Win+... shortcut[/+]Windows: Wait for Win modifier to be released before sending copy/paste
hluk commentedon Feb 12, 2026
I'm trying to fix it in #3426. Can you test the behavior with this development build?
Chealer commentedon Feb 12, 2026
Ah, thank you Lukas
I confirm that will fix it.
For what it's worth, I typed very slowly to verify, which led me to notice the same symptom, but in different conditions. This is now tracked in ticket #3428.
Windows: Wait for Win modifier to be released before sending copy/paste