Clipboard
Use pyperclip module to use text from computer's clipboard.
"""A program which uses the computer's clipboard,
using pyperclip package, by Al Sweigart
Pyperclip is not part of the standard distribution.
pip install pyperclip
"""
import pyperclip, time
pyperclip.copy('Hello, world!')
clipboard = pyperclip.paste()
print(clipboard)
# Hello, world!
while(True):
clipboard = pyperclip.paste() # Look Here
print(clipboard)
time.sleep(5)
# Hello, world!
# Hello, world!
# Hello, world!
# ...
# copy another text on computer
# example: a path from terminal
# ---
# /usr/bin/python3
# /usr/bin/python3
# /usr/bin/python3
Multi Clipboard
Multi clipboard CLI program with keyphrase as argument.
"""A program that can be run with command line arguments
(a short keyphrase like: agree or busy)
This way the user can have long related text in clipboard,
without having to retype all text.
Usage: python multiclipboard.py [keyphrase]
"""
import sys, pyperclip
TEXT = {
'agree': """I agree, that sounds fine to me.""",
'busy': """Sorry, I am not available right now.""",
}
if len(sys.argv) < 2:
print('Correct usage: py multiclipboard.py [keyphrase]')
print('To copy phrase text in the clipboard')
sys.exit()
key = sys.argv[1]
if key not in TEXT:
print(f'There is no text for [{key}]')
sys.exit()
pyperclip.copy(TEXT[key])
print(f'Text for [{key}] copied to clipboard.') # Look Here
"""
$ python multiclipboard.py something
# There is no text for [text]
$ python multiclipboard.py agree
# Text for [agree] copied to clipboard.
$ Ctrl + Shift + V
# I agree, that sounds fine to me.
"""
Bullets
Python script to automatically add bullets to a list.
"""Add bullets to a list
The tranformed list will be automatically ...
available in the clipboard.
Copy:
Name: pyperclip
Version: 1.8.2
Author: Al Sweigart
License: BSD
Run:
$ python bullets.py
Paste:
* Name: pyperclip
* Version: 1.8.2
* Author: Al Sweigart
* License: BSD
"""
import pyperclip
text = pyperclip.paste()
lines = text.split('\n')
lines = [f'* {k}' for k in lines]
text = '\n'.join(lines)
pyperclip.copy(text) # text ready to be paste
Last update: 386 days ago