Skip to content

copy() throws “Failed to copy to clipboard!” if triggered using Win+... shortcut #3398

Closed

Description

@Chealer

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:

  1. ⊞ Win+Y
  2. ⊞ Win+Alt+Z
  3. ⊞ 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:

  1. Change the shortcut to ⊞ Win+Y
  2. Select this text
  3. 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)

License This report (including all messages and attachments I add to it) is offered under the terms of CC0 1.0.

Activity

  1. changed the title [-]`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[/+] on Jan 26, 2026
  2. added
    help wantedNeeds a volunteer to investigate/implement the issue
    WindowsRelates to Windows OS
    on Feb 12, 2026
  3. changed the title [-]`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[/+] on Feb 12, 2026
  4. removed
    help wantedNeeds a volunteer to investigate/implement the issue
    on Feb 12, 2026
  5. added a commit that references this issue on Feb 12, 2026
    0c956ae
  6. hluk commented on Feb 12, 2026

    @hluk
    Owner

    I'm trying to fix it in #3426. Can you test the behavior with this development build?

  7. Chealer commented on Feb 12, 2026

    @Chealer
    ContributorAuthor

    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.

  8. added a commit that references this issue on Feb 12, 2026
    d22e4a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    WindowsRelates to Windows OSbug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions