0

Hey guys I'm working with this textbook Automate the Boring Stuff and I've made it all the way to chapter 8 with no problems, but I'm having trouble with the Multiclipboard Project. Specifically, how do I start it?

I type py mcb.pyw save spam into the python shell but it just says invalid syntax.

Here's the rest of the code to the script.

#! 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')

# Save clipboard content.
if len(sys.argv) == 3 and sys.argv[1].lower() == 'save':
    mcbShelf[sys.argv[2]] = pyperclip.paste()
elif len(sys.argv) == 2:
# List keywords 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()
LiteCoder
  • 1
  • 2

1 Answers1

0

Have you tried:

 py.exe mcb.pyw save <keyword> - Saves clipboard to keyword.

That is what is listed as the usage command in your code. If you are on windows you may need to include the .exe for it to work.

Eric
  • 159
  • 2
  • 11