Last active
July 9, 2019 00:07
-
-
Save fractaledmind/6662572 to your computer and use it in GitHub Desktop.
Interact with the Pasteboard via Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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