Processing: Copy a text string to clipboard

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

1
import java.awt.datatransfer.Clipboard;
2
import java.awt.datatransfer.Transferable;
3
import java.awt.datatransfer.StringSelection;
4
import java.awt.Toolkit;
5
6
void CopyToClipboard(String s)
7
{
8
	Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
9
	StringSelection data = new StringSelection(s);
10
	clipboard.setContents(data, data);
11
}

The code above worked on my Windows 10. It uses the ancient Java (not a script), how nostalgy.

References🙇

Prev前の記事

前の記事のアイキャッチ画像
Processingで文字列をクリップボードにコピーする

Next次の記事

アイキャッチ画像
【VR】「Half-Life: Alyx」レビュー。良いところとイマイチなところ。