Skip to content

Instantly share code, notes, and snippets.

@fractaledmind
Last active July 9, 2019 00:07
Show Gist options
  • Select an option

  • Save fractaledmind/6662572 to your computer and use it in GitHub Desktop.

Select an option

Save fractaledmind/6662572 to your computer and use it in GitHub Desktop.
Interact with the Pasteboard via Python
import subprocess
def getClipboardData():
p = subprocess.Popen(['pbpaste'], stdout=subprocess.PIPE)
retcode = p.wait()
data = p.stdout.read()
return data
def setClipboardData(data):
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
p.stdin.write(data)
p.stdin.close()
retcode = p.wait()
x = getClipboardData()
print x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment