Multiple Clipboards

with AutoHotkey

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

by Denis Lamarre


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.



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.


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

  ClipSaved := ClipboardAll ;Save the clipboard
  Clipboard = ;Empty the clipboard
  SendInput, ^c
  ClipWait, 2
  if ErrorLevel
    MsgBox % "Failed attempt to copy text to clipboard."
  NewClipboard := Trim(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


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

ClipBoard_X := GetFromClipboard()

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

SendInput {Raw}%ClipBoard_X%

More Info

“GetFromClipboard()” will remove all extra spaces and tabs at the beginning and at the end of the clipboard. Also “GetFromClipboard()" is tuned to copy/paste 'text.' It doesn’t copy/paste pictures. You can easily modify “GetFromClipboard()” if you need to copy/paste pictures.