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.

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.



Paste and Copy text – Processing 2.x and 3.x Forum

What is the simplest way to copy to the clipboard from processing? – Processing Forum


Email won't be published. Or you can leave it blank. I mean you can leave everything blank but comment. Feel free to leave a comment, thanks.