Processing: Copy a text string to clipboard
I'm starting to try Processing, which is a program language... or a IDE? Graphic tool? I'm struggling with the syntax like I always forget "; (semi-colon)", since the language I was using lately is Python for blender script. But it's fun like I could make a tool for my own even it was my very first day of Processing 3.
I thought it is only for graphic processing, but actually it has some affinity to OS itself. It can copy a string to system's clipboard.
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.StringSelection;
import java.awt.Toolkit;
void CopyToClipboard(String s)
{
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection data = new StringSelection(s);
clipboard.setContents(data, data);
}
The code above worked on my Windows 10. It uses the ancient Java (not a script), how nostalgy.
References🙇
Paste and Copy text - Processing 2.x and 3.x Forum
https://forum.processing.org/two/discussion/27473/paste-and-copy-text
What is the simplest way to copy to the clipboard from processing? - Processing Forum
https://forum.processing.org/one/topic/what-is-the-simplest-way-to-copy-to-the-clipboard-from-processing#25080000000067184.html
この記事はここで終わりです。
読んでいただきありがとうございました。
良かったらシェアしてね!
That's all for this article. Thank you for your reading.
Please share this if you like it!