0
Is the clipboard easy to manipulate?
3 Respuestas
+ 7
Javascript
You can copy to clipboard from text inputs only. If you want to copy any text content you need to be creative.
Maybe create hidden text input or textarea element. Change the value of it and use select() on it which highlights the content inside.
document.execCommand('copy');
Will copy the content inside the selected text input.
There's no good way to read the current clipboard value.
+ 1
Python has a library for this, its pretty easy and straight forward:
https://pyperclip.readthedocs.io/en/latest/introduction.html
#From the docs
import pyperclip
pyperclip.copy('Hello world!')
pyperclip.paste()