I\'d like my python program to place some text in the Mac clipboard.
Is this possible?
The following code use PyObjC (https://pyobjc.readthedocs.io)
from AppKit import NSPasteboard, NSArray
pb = NSPasteboard.generalPasteboard()
pb.clearContents()
a = NSArray.arrayWithObject_("hello world")
pb.writeObjects_(a)
As explained in Cocoa documentation, copying requires three step :
You fill the pasteboard with an array of object (here a
contains only one string).