How to script Copy Paste Clipboard right mouse click

The script that we use for the actual copy to clipboard is:

from java.awt import Toolkit
from java.awt.datatransfer import StringSelection
	
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
clipboard.setContents(StringSelection(text_to_copy), None)

The script is inside a function that takes the text of the component (text_to_copy) as a parameter.

4 Likes