Editing <span id="firstHeadingTitle">Clipboardbuffers.py</span>
Read
Edit
View history
Not logged in
Talk
Contributions
Create account
Log in
Editing
Clipboardbuffers.py
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
import sys import os import time import pyperclip import pyautogui as pg from PyHotKey import Key, keyboard import pickle import tkinter as tk #pg.prompt(text="deez nuts?", title="deez nutz!", default="deez nars") def dumpClipboardBufferToFile(): global clipboardBuffer with open("clipboardBufferData.pk", 'wb') as fi: pickle.dump(clipboardBuffer, fi) def getClipboardBufferFromFile(): global clipboardBuffer with open("clipboardBufferData.pk", 'rb') as fi: clipboardBuffer = pickle.load(fi) #scriptFolder = (os.path.dirname(__file__)) clipboardBuffer = [] clipboardBuffer = ["No value in this clipboard buffer" for i in range(10)] #check if pickle file exists, if not, then create one if os.path.isfile("clipboardBufferData.pk"): getClipboardBufferFromFile() else: dumpClipboardBufferToFile() def inputbox(inputBuffer): inputText = "No Input Given Yet" window = tk.Tk() window.title('clipboardbuffers') textbox = tk.Entry(window, width=400) textbox.pack() textbox.insert(0, clipboardBuffer[inputBuffer]) textbox.focus_set() def entry_select_all(event): event.widget.select_range(0, 'end') event.widget.icursor('end') return 'break' def entry_ctrl_backspace(event): end_idx = textbox.index(tk.INSERT) start_idx = textbox.get().rfind(" ", None, end_idx) textbox.selection_range(start_idx, end_idx) def onclick(pos): nonlocal inputText inputText = textbox.get() global clipboardBuffer clipboardBuffer[inputBuffer] = inputText print(f"Clipboard buffer {inputBuffer} was set to: {inputText}") window.destroy() b = tk.Button(window, text="OK", width=10, command=onclick) b.pack() textbox.bind('<Return>', onclick) textbox.bind('<KP_Enter>', onclick) textbox.bind('<Control-BackSpace>', entry_ctrl_backspace) textbox.bind('<Control-Key-a>', entry_select_all) window.mainloop() print(clipboardBuffer) dumpClipboardBufferToFile() return (inputText) def typeBuffer(inputBuffer): global clipboardBuffer # pyautogui.write(clipboardBuffer[inputBuffer]) keyboard.type(clipboardBuffer[inputBuffer]) def copyToBuffer(inputBuffer): global clipboardBuffer clip = pyperclip.paste() clipboardBuffer[inputBuffer] = clip print(clipboardBuffer[inputBuffer]) dumpClipboardBufferToFile() if sys.argv[1] == "paste": typeBuffer(int(sys.argv[2])) if sys.argv[1] == "copy": copyToBuffer(int(sys.argv[2])) if sys.argv[1] == "edit": inputbox(int(sys.argv[2]))
Summary:
Please note that all contributions to Lucca's Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Lucca's Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
🎨 Theme Settings
Quick Presets
Code & Pre Block Text Color
Code / Pre Text Color
Background
Primary Background
Secondary Background
Tertiary Background
Hover Background
Text
Primary Text
Secondary Text
Muted Text
Accent & Borders
Accent
Accent Dim
Border
Border 2
Header & Sidebar
Header Start
Header End
Sidebar Background
Status Colors
Success
Danger
Warning
Reset to Default
Save & Close