← Back to Blog

Developers & Code | Published Aug 21, 2026 | Updated Oct 13, 2026 | 7 min read

CopyQ Scripting: 5 Automations Worth Setting Up

By Deepender Yadav

CopyQ Scripting: 5 Automations Worth Setting Up — Edge Drop Guide

CopyQ commands are small scripts that run when the clipboard changes, when you pick them from a menu, or when you press a global shortcut. You add them in the Command dialog (press F6 in the CopyQ window). The five most useful for everyday work are: ignoring copies from a password manager window, refusing to store anything that looks like an API key, redacting keys before they're saved, routing copies from one app into their own tab, and pasting as plain text on a hotkey. All five are below, built only from features in CopyQ's documentation.

How CopyQ commands work

Open the Command dialog with F6 (or File > Commands/Global Shortcuts…). Click Add to choose a predefined command or New Command to start from scratch. Each command has a type:

TypeWhen it runs
AutomaticEvery time the clipboard changes, in list order
In MenuFrom the item context menu, the tray menu or its own shortcut
Global ShortcutFrom a system-wide shortcut, even when CopyQ isn't focused
ScriptLoaded before other scripts, to override or add functions
DisplayChanges how items look, without changing what's stored

Automatic and In Menu commands can be limited with Content (a regular expression matched against the text), Window (a regular expression matched against the title of the window you copied from), Format and Filter. Actions such as Copy to tab and Remove Item need no code at all. When a command does need code, the Command field takes a shell command, a script prefixed with an interpreter such as powershell:, or CopyQ's own JavaScript-like scripting prefixed with copyq:.

One rule matters for the privacy commands below: automatic commands run top to bottom, and when one uses Remove Item or calls ignore(), the clipboard isn't stored and later automatic commands don't run. Put privacy commands at the top of the list.

1. Ignore copies from a password manager window

CopyQ already skips clipboard content that's marked as secret. On Windows that means data carrying Clipboard Viewer Ignore or ExcludeClipboardContentFromMonitorProcessing, or with CanIncludeInClipboardHistory or CanUploadToCloudClipboard set to 0, which most password managers set. For an app that doesn't mark its copies:

  1. Press F6, click Add, select Ignore *Password* window and click OK.
  2. Click Show Advanced.
  3. Change the Window box to match the app's window title, for example KeePass.
  4. Move the command to the top of the list and click OK.

If the app copies from a popup menu rather than its main window, CopyQ's FAQ suggests setting Window to ^$, which usually matches menus.

2. Don't store anything that looks like a key

This one needs no script. Create a New Command with:

  • Type: Automatic
  • Content: AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{36}|-----BEGIN [A-Z ]*PRIVATE KEY-----
  • Action: Remove Item

That pattern matches AWS access key IDs, classic GitHub personal access tokens and PEM private key headers. Any copy containing one is dropped from history entirely, and later automatic commands skip it. Add patterns for the services you use, separated by |. The copy itself still pastes normally; it just isn't kept.

3. Redact keys instead of dropping the whole copy

Sometimes you want the log or stack trace in history, just without the token in it. An automatic command can rewrite the item before CopyQ stores it, the same technique CopyQ's own "Remove Background and Text Colors" example uses. Set Type to Automatic and paste this into the Command field:

copyq:
var text = str(data(mimeText))
var clean = text
  .replace(/AKIA[0-9A-Z]{16}/g, 'AKIA[REDACTED]')
  .replace(/Bearer\s+[A-Za-z0-9._~+\/-]+=*/g, 'Bearer [REDACTED]')
if (clean != text) {
  setData(mimeText, clean)
  removeData(mimeHtml)
}

setData replaces the plain text that gets saved, and removeData(mimeHtml) drops the rich-text copy, which would otherwise still contain the original. This changes what CopyQ stores, not the live clipboard, so the next paste still has the real value. Pattern lists need upkeep: add a line whenever you start working with a new kind of token.

4. Send copies from VS Code to their own tab

Again no script is needed. Create a New Command with:

  • Type: Automatic
  • Window: Visual Studio Code$ (VS Code's window titles end with its name)
  • Action: Copy to tab, with the tab name code

Every copy made in VS Code now also lands in a code tab, so snippets aren't buried under browser and chat copies. Repeat with other window patterns for a terminal or browser tab. CopyQ's command examples include a Window Tabs script that goes further and creates a tab for each source window automatically.

5. Paste as plain text on a global shortcut

Create a New Command with Type set to Global Shortcut, assign a shortcut you don't use elsewhere, and paste this into the Command field:

copyq:
copy(str(clipboard()))
paste()

clipboard() returns the clipboard's plain text, copy() puts back only that text, and paste() sends a paste keystroke to the active window. Note that CopyQ's paste() sends Shift+Insert by default; if an app ignores that, run config('window_paste_with_ctrl_v_regex', '.*') once (for example with copyq eval) so CopyQ sends Ctrl+V instead, or replace .* with a pattern matching that app's window title. For the same job without CopyQ, see how to paste without formatting on Windows, and for other one-step transforms, changing the case of pasted text.

Sharing and backing up commands

In the Command dialog, select commands and use Copy Selected (or Ctrl+C) to put them on the clipboard as text, or Save Selected Commands… to write a file. Paste or Load Commands… on another PC to import them. That's also how the examples in CopyQ's documentation are installed: copy the [Command] block from the page and paste it into the command list.

Using CopyQ from the command line

The copyq command controls a running CopyQ instance, which makes it easy to call from scripts:

copyq tab notes add "Text saved from a script"
copyq tab notes read 0
copyq eval -- "tab('notes'); print(size())"

On Windows, CopyQ may print nothing in PowerShell or Command Prompt. The documented workaround is to pipe through Write-Output, for example & 'C:\Program Files\CopyQ\copyq.exe' read 0 | Write-Output, or to use Git Bash.

Privacy notes before you automate

  • CopyQ stores tab data unencrypted in its configuration folder unless you enable its Encryption feature.
  • Automatic commands see everything that isn't marked secret. Keep commands that send data elsewhere (a translation service, a webhook) out of the Automatic list, or limit them with a Window or Content rule.
  • CopyQ states that it doesn't collect data or send anything over the network on its own.

How to stop clipboard managers from saving secrets covers the same problem across other tools.

Other ways to script the Windows clipboard

ToolHow you automateRuns on every copy?
CopyQCommands in its JavaScript-like scripting, plus a CLIYes, with Automatic commands
ClipboardFusionCustom C# macros, triggersRunning triggers on clipboard change needs the paid Pro edition
AutoHotkey v2Scripts with OnClipboardChange and hotkeysYes, while the script runs
PowerShellGet-Clipboard and Set-Clipboard in your own scriptsNo, only when you run them
Power Automate for desktopGet and Set clipboard text actions in a flowNo, only when the flow runs
Win+V, Edge DropNo scripting or pluginsNot applicable

AutoHotkey is the usual choice when you want hotkeys and text transforms without a full clipboard manager; the best AutoHotkey clipboard scripts has working v2 examples, and the PowerShell clipboard cheat sheet covers one-off transforms. Edge Drop is a visual shelf for dragging images and files and has no scripting layer; if you want both, running two clipboard tools at once explains what to watch for.

FAQ

Does CopyQ use JavaScript?

CopyQ's documentation describes its scripting language as JavaScript-like: ordinary JavaScript syntax plus functions for clipboard access such as copy(), paste(), data() and setData(). Commands can also run PowerShell, Python or any shell command instead.

Why doesn't my automatic command run?

Check that it's ticked, that an earlier command isn't removing the item first, and that its Content, Window or Format rules match. Copies marked as secret never reach automatic commands.

Do these commands work on Linux and macOS?

CopyQ runs on Windows, Linux and macOS, and copyq: scripts use the same functions everywhere. Window titles, file paths and shell commands differ between systems, so check any Window pattern or powershell: command when you move a command to another OS. On Linux, CopyQ competes with each desktop's own tool; Linux clipboard managers for GNOME, KDE and Wayland compares them.

Related reading

Sources

Deepender Yadav
Written by Deepender Yadav · Creator & Developer

Deepender Yadav created Edge Drop and builds and tests it, from the edge-hover shelf to each release. A B.Tech Computer Science Engineering student, Deepender writes the Edge Drop guides, comparisons and developer posts, and checks product details against the app's source code.

GitHub · LinkedIn

Copy. Stack. Drop.

Transform your clipboard into an interactive edge shelf. Stack, pin, and drag assets into any app with zero friction.

Download for Windows Get from Microsoft Store

How to Install Guide · First 10 Minutes Guide · Drag & Drop Guide · Edge Drop vs Win+V · Support

Free · Lightweight · Privacy First
Find us on CodeHype