Paste and Go Snippet

Good evening

I am trying to create a snippet which does not require any input but rather takes the existing content of the system clipboard and pastes it with a carriage return at the end.

I tried this but it does not work - I am having difficulity figuring out how to access the contents of the clipboard within Javascript.

Can you help?

popclip

name: Paste and Go
icon: square P-G
requirements: [’!text’]
javascript: |
{ popclip.pasteText (navigator.clipboard.text + ‘\n’ ) }
#end

1 Like

Sure thing —
The current clipboard contents are accessed using pasteboard.text and this code ought to do it:

#popclip
name: Paste and Go
icon: square P-G
requirements: [paste]
javascript: popclip.pasteText(pasteboard.text + '\n')

I changed the requirement to “paste” which I think might more closely match what you want.

Sorry this stuff is not easy to find the documentation for yet. For now just ask questions!

p.s.

if you want it to actually press the enter key rather than paste a newline charcater in the string (subtly different):

#popclip
name: Paste and Go
icon: square P-G
requirements: [paste]
javascript: |
  popclip.pasteText(pasteboard.text)
  popclip.pressKey(util.constant.KEY_RETURN)
1 Like

Great - many thanks Nick

1 Like