Skip to content

Instantly share code, notes, and snippets.

@CodyKochmann
Created May 8, 2015 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodyKochmann/80dddff75fb11ea41552 to your computer and use it in GitHub Desktop.
Save CodyKochmann/80dddff75fb11ea41552 to your computer and use it in GitHub Desktop.
python functions that give clipboard access to the script
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()
print getClipboardData()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment