Clipboard Scripting

Clipboard transformation offers several benefits:

  • Grouped Editing: Apply complex transformations that involve multiple steps by chaining commands within a script. This simplifies the process compared to applying individual edits sequentially.
  • Customizable Workflows: Craft scripts that group specific editing needs within your workflow. You can group commands for text formatting, data manipulation, or text cleaning.
  • Reduced Manual Editing: Automate repetitive edits within the current content of the editor or the Clipboard by applying a pre-defined script. This saves time and ensures consistency.

Available in QCE v2.1 or more recent, a Script allows to group Quick Clipboard Editor (QCE) commands and achieve powerful and efficient editing within Quick Clipboard Editor or in any other application that allows script execution.

A Script can include:

  • Change case commands (upper case, lower case, title case, etc.);
  • Saved commands to insert or remove string on each line, filter characters or lines, reformat paragraphs, etc. (see below);
  • Convert commands (HTML, Base64, etc.).

This type of automation can be done in two ways:

  • 1) Within the Quick Clipboard Editor: to create a Script, select the menu Commands, Script. In the Script text box, enter the commands to execute (see below), one on each line; you can save the script as you would save other commands.
  • 2) From any program that can “Run” a Windows executable, batch file or script: use the QCE companion program QCEmessenger.exe to launch commands that will be applied immediately to the content of the Clipboard. No need to open the QCE editor! See how to execute transformations using QCEmessenger.

Commands

Here are the commands that you can execute within a script or using QCEmessenger. Remember that these command can be executed on the current content of the editor using a Script or on the current content of the editor using QCEmessenger.

Change Case commands

The Case command allows to automatically change the case of the text (see the Change case help). Enter the following command:

Case <case type>
Case Lower

Available case types are:

  • Lower
  • Upper
  • Title
  • Sentence
  • Toggle
  • SaRcAsM
  • Random

Executing Saved commands

The Exec command can be used to launch Saved commands (see the Saved commands help). This allows to apply various transformation to the content of the editor or the Clipboard:

  • Insert string, Substring, Filter lines, Filter characters, Reformat paragraphs
  • Open and Save file, Backup and Restore Clipboard
  • Find, Find and replace, Sort

To execute a QCE Saved command, enter the following command:

Exec <name of the saved command>
Exec "My saved command"

Note: If you launch the Saved command using QCEmessenger, make sure to enclose its title between double quotes if the title includes one or more spaces. This can be omitted when using the Exec command within QCE with a Script.

Encode-Decode commands

The Encode and Decode commands allow to convert the text (see the Convert help). To execute one of the encode/decode commands, enter the following commands:

Encode <encoding type>
Decode <encoding type>

Encode HTML
Decode URI

Available encoding types are:

  • URI
  • XML
  • XML (Numeric)
    – specify the character(s) to convert to numeric values in a third parameter
    – for example Encode XML &$ (to numerically encode & and $)
  • Hex
  • ASCII
  • HTML
  • PHPDouble
  • PHPSingle
  • AHK
  • AHKVarExpression
  • ClipboardAllBase64
  • ClipboardImageBase64

Sleep

If you need to give some time to QCE between two commands, use the Sleep command with the number of milliseconds to wait before continuing with the next command. For example to wait 1 second:

Sleep 1000

Example from within QCE

This working example will show you how to build the pieces required to execute a sequence of command to achieve your goal using a Script within QCE (see below for an example using a script triggered from an external program using QCEmessenger).

Assuming the editor contains this list of files…

O:\Temp\item4682-Window.png
O:\Temp\item9375-Window.png
O:\Temp\item7355-Window.png
O:\Temp\item8115-Window.png

… and that you want to transform this list as this reverse sorted list of codes:

ITEM9375
ITEM8115
ITEM7355
ITEM4682

This script will do the transformation:

Exec Sort Reverse
Exec Keep from position 9 for 8 characters
Case Upper

In order to execute this script, you will first have to create two Saved commands. Open Command, Sort and save the following command under the name Sort Reverse.

And, to create the second command, open Command, Substring and save the following command under the name suggested when you click the Suggest button.

The third command Case Upper does not have to be created. It exists built-in in QCE as other Case and Convert commands. You are now ready to create your script:

Click Execute to launch your script. Click Save this command if you want to reuse your script.

Example using QCEmessenger

This example will show how execute the commands above from an external application or script to transform the current content of the Clipboard using QCEmessenger (see how to execute transformations using QCEmessenger).

Assuming the Clipboard contains the list of files shown above, create a batch file and enter the following commands (adapt the QCEmessenger.exe path to your own configuration:

"C:\Program Files\Quick Clipboard Editor\QCEmessenger.exe" Exec "Sort Reverse"
"C:\Program Files\Quick Clipboard Editor\QCEmessenger.exe" Exec "Keep from position 9 for 8 characters"
"C:\Program Files\Quick Clipboard Editor\QCEmessenger.exe" Case Upper
pause

The pause command at the end is not required but it will help you if your batch needs to be reviewed or debugged. Do not forget to enclose the file paths and parameters between double quotes if they contain spaces. Save your batch file under the name QCEexample.bat and run it to transform the current content of your Clipboard.