Multiple Clipboards

with AutoHotkey

by Denis Lamarre
last updated Jun 24, 2013
difficulty.png Intermediate

by Denis Lamarre

Description

Often people need to copy text from one application to another. The sequence is always the same; highlight the text to be copied and then copy it, then switch to the second application, paste the text and then repeat again and again. The repetitive sequence of "ctrl+c", "alt+tab", "ctrl+v", "alt+tab" is a good way to develop stress.

Imagine the benefits of using several clipboards at the same time to save the time and repetitive motions of going back and forth between applications. The number of clipboards needed is dependent on your situation and what you are trying to accomplish. Three is a good number to start with: one key on the Enterpad can be used to copy to the first clipboard, another key to copy to the second clipboard, and another one to copy to the third clipboard. You need another set of three keys for pasting.

Note: AutoHotkey has no limits when it comes to automation in Windows, but for many users who may only need simple keyboard shortcuts, installing and learning AutoHotkey, and keeping up to date, can be overkill. ShortKeeper can be used (with and without an Enterpad) to manage an AutoHotkey-based system in a way most non-programmers will find remarkably user-friendly and and effective [learn more].

Steps

1

stencil-v3-clipboard.gifPrepare your overlay.
Experience has shown that it is best to group the six keys together with each "copy" key above its "paste" key on the Enterpad. So if you want to start with the first key on the Enterpad: key1=copy1, key2=copy2, key3=copy3, key11=paste1, key12=paste2, key13=paste3.

2

Code installation.
Copy this function at the end of your AutoHotkey script file (Enterpad.ahk).

SetClipboard()
{ 
ClipSaved := ClipboardAll ;Save the clipboard 
Clipboard = ;Empty the clipboard
SendInput, ^c 
ClipWait, 2 
if ErrorLevel 
{
     MsgBox % "The attempt to copy text into the clipboard failed."
     return 
} 
NewClipboard = %clipboard%
StringReplace, NewClipboard, NewClipBoard, `r`n, `n, All 
Clipboard := ClipSaved ;Restore the clipboard 
ClipSaved = ;Free the memory in case the clipboard was very large. 
Return NewClipboard 
}

3

Setup your keys.
Then, use this code for each of your “copy” keys (replacing X with your clipboard number):

ClipBoard_X := SetClipboard()
return

And finally use this code for each of your “paste” keys (replacing X with your clipboard number):

SendInput {Raw}%ClipBoard_X%
return

More Info

“SetClipboard()” will remove all extra spaces at the beginning and at the end of the clipboard if the AHK’s variable “AutoTrim” is set to “ON” (this is the default setting). Also “SetClipboard()" is tuned to copy/paste 'text.' It doesn’t copy/paste pictures. You can easily modify “SetClipboard()” if you need to copy/paste pictures.