From 75a42ec54dbf721caa659ddf02c1f46fc2cb4bef Mon Sep 17 00:00:00 2001 From: mlot Date: Fri, 6 Jun 2025 13:40:57 -0400 Subject: initial commit for archiving --- Chap8ProjMcb.pyw | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Chap8ProjMcb.pyw (limited to 'Chap8ProjMcb.pyw') diff --git a/Chap8ProjMcb.pyw b/Chap8ProjMcb.pyw new file mode 100644 index 0000000..c06035e --- /dev/null +++ b/Chap8ProjMcb.pyw @@ -0,0 +1,26 @@ +#! usr/bin/env python3 + +# Chapter 8 Multiclipboard project + +# Loads and saves clipboard text based on a key word from the command line +# Usage: py.exe mcb.pyw save - Saves to clipboard +# py.exe mcb.pyw - Loads keyword to clipboard +# py.exe mcb.pyw list - Loads all keywords to clipboard + +import sys +import pyperclip +import shelve + +mcbShelf = shelve.open('mcb') + +if len(sys.argv) == 3 and sys.argv[1].lower() == 'save': + mcbShelf[sys.argv[2]] = pyperclip.paste() +elif len(sys.argv) == 2: + 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() + -- cgit