Here’s what the program does:
• The command line argument for the keyword is checked.
• If the argument is save, then the clipboard contents are saved to the
keyword.
• If the argument is list, then all the keywords are copied to the clipboard.
• Read the command line arguments from sys.argv.
• Read and write to the clipboard.
• Save and load to a shelf file.
#! python3
# mcb.pyw - Saves and loads pieces of text to the clipboard.
# Usage: py.exe mcb.pyw save <keyword> - Saves clipboard to keyword.
# py.exe mcb.pyw <keyword> - Loads keyword to clipboard.
# py.exe mcb.pyw list - Loads all keywords to clipboard.
import shelve, pyperclip,sys
mcbShelf = shelve.open('mcb')
#TODO: save clopboard content
#TODO: list keywordsand load content
# save clopboard content
if len(sys.argv) == 3 and sys.argv[1].lower()=='save':
mcbShelf[sys.grgv[2]] = pyperclip.paste()
elif len(sys.argv)==2:
#TODO: list words and load content
if sys.argv[1].lower()=='list':
pyperclip.copy(str(list(mcbShelf.keys())))
elif sys.argv[1] in mcbShelf:
pyperclip.copy(mcbShelf[sys.argv[1]])
mcbShelf.close()