閉じる

UI言語[UI Language]

記事自体は翻訳されません! 記事によって英語版があったりなかったりします。翻訳がある記事は文頭に記載があるよ!
Each articles themselves will not be translated by this setting. Some of article has translation and some of them doesn't. You will notice if the article has its translation by its preamble!

テーマ[Theme]


アイキャッチ画像

Processing: Copy a text string to clipboard

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

References🙇

この記事のタグ[This article is filed under]: 開発[Dev] | ハウツー[How to] | Java[Java] | Processing[Processing] | 英語の記事[Written in English]


この記事はここで終わりです。
読んでいただきありがとうございました。
良かったらシェアしてね!

That's all for this article. Thank you for your reading.
Please share this if you like it!

Twitter | Reddit | Facebook | Pinterest | Pocket

前の記事[Prev Post]

前の記事のアイキャッチ画像

Processingで文字列をクリップボードにコピーする

次の記事[Next Post]

次の記事のアイキャッチ画像

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