Friday, October 22, 2021

#1 2021-09-25 11:49:47 am

Registered: 2011-08-20
Posts: 63

Select 1 of the 4 System Clipboards & View its Contents

I constantly find myself utilizing all 4 system clipboards.  One way I do this is by sending what’s currently in my clipboard (general) to 1 of the other 3 available clipboards (find, font, or ruler).

This is a shortened version of the code I use to store what’s currently on my clipboard to a different clipboard.


property theClipboards : {"general", "find", "font", "ruler"}

set chosenClipboard to (choose from list theClipboards ¬
   with title "Choose Your Desired Clipboard" with prompt ¬
   "Send The Content Of Your Main Clipboard To A Different Clipboard" default items ¬
   "font" OK button name "OK" cancel button name "Cancel") as string

do shell script "pbpaste -pboard general | pbcopy -pboard " & ¬
   quote & chosenClipboard & quote

The problem is though, after doing this a few times, you start to forget which clipboard has which data.  Sometimes this turns into a nightmare.  This following code is my solution to that problem.  It allows you to choose a certain clipboard and view it's contents quickly.


property theClipboards : {"general", "find", "font", "ruler"}

set chosenClipboard to item 1 of (choose from list theClipboards ¬
   with title "Choose A Clipboard" with prompt ¬
   "Choose a clipboard to view its contents." OK button name ¬
   "View Chosen Clipboard" cancel button name "Cancel")

set theResult to displayClipboard(chosenClipboard)

display dialog theResult buttons {"OK"} default button 1 ¬
   with title ("Contents of Pasteboard " & chosenClipboard) giving up after 5

to displayClipboard(chosenClipboard)
   set theResult to (do shell script "pbpaste -pboard " & chosenClipboard)
end displayClipboard

Last edited by wch1zpink (2021-09-25 12:18:32 pm)

Filed under: clipboard, pbcopy, pbpaste



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)