Multiple Clipboards

with AutoHotkey

by Denis Lamarre
last updated Nov 22, 2018
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, 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, preventing you from having to go 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.

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 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.

2

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

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

3

Setup your keys
Use this code for each of your "copy" keys (replacing X with your clipboard number):

ClipBoard_X := GetFromClipboard()
return

Finally, use this code for each of your "paste" keys (replacing X with your clipboard number):

SendInput {Raw}%ClipBoard_X%
return

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.