Multiple Clipboards

with AutoHotkey

by Denis Lamarre
last updated Nov 22, 2018
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, copy it, then switch to the second application, place the cursor at the desired location, and paste the text. Doing this over and over again — pressing Ctrl+C, Alt+Tab, Ctrl+V, and Alt+Tab — is a good way to develop stress.

Imagine the benefits of using several clipboards simultaneously, allowing you to avoid having to switch back and forth between applications. The number of clipboards you use will depend on your situation. Three is a good number to start: one key on the Enterpad to copy to the first clipboard, another key to copy to the second, and another to copy to the third. You will also 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 respective "Paste" key. So, if you start with the first key on the Enterpad, it would look like this: key #1=Copy1, key #2=Copy2, key #3=Copy3, key 11=Paste1, key #12=Paste2, key #13=Paste3.


Code installation
Copy and paste this function at the end of your AutoHotkey script template (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
Use this code for each of your "Copy" keys (replacing X with your clipboard number):

ClipBoard_X := GetFromClipboard()

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 end of the clipboard. Also "GetFromClipboard()" is designed to copy and paste text only (i.e. it doesn’t copy/paste images). You can easily modify "GetFromClipboard()" if you need to copy and paste images.