Clipboardbuffers.py: Difference between revisions
From Lucca's Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
import os | import os | ||
import sys | import sys | ||
from threading import Event | |||
from PyHotKey import Key, keyboard | from PyHotKey import Key, keyboard | ||
keyboard.suppress_hotkey = True | |||
from tkinter import * | from tkinter import * | ||
scriptFolder = (os.path.dirname(__file__)) | scriptFolder = (os.path.dirname(__file__)) | ||
clipboardBuffer = [] | |||
clipboardBuffer = ["No value in this clipboard buffer" for i in range(10)] | |||
def inputbox(inputBuffer): | def inputbox(inputBuffer): | ||
inputText = "No Input Given Yet" | |||
master = Tk() | |||
textbox = Entry(master) | |||
textbox.pack() | |||
textbox.focus_set() | |||
def onclick(pos): | |||
nonlocal inputText | |||
inputText = textbox.get() | |||
global clipboardBuffer | |||
clipboardBuffer[inputBuffer] = inputText | |||
print(f"Clipboard buffer {inputBuffer} was set to: {inputText}") | |||
master.destroy() | |||
b = Button(master, text="OK", width=10, command=onclick) | |||
b.pack() | |||
textbox.bind('<Return>', onclick) | |||
mainloop() | |||
print(clipboardBuffer) | |||
return (inputText) | |||
def typeBuffer(inputBuffer): | |||
keyboard.type("\b"+clipboardBuffer[inputBuffer]) | |||
#Hotkeys go here!!# | |||
for x in [1,2,3,4,5,6,7,8,9]: | |||
keyboard.register_hotkey([Key.cmd, Key.shift, str(x)], None, inputbox, x) #windows key + 1,2,3,4,5,6,7,8,9,etc | |||
keyboard.register_hotkey([Key.cmd, str(x)], None, typeBuffer, x) #windows key + 1,2,3,4,5,6,7,8,9,etc [https://pynput.readthedocs.io/en/latest/keyboard.html] | |||
#Hotkeys go here!!# | |||
print(keyboard.hotkeys) | print(keyboard.hotkeys) | ||
import threading | |||
event = threading.Event() | |||
event.wait() |
Revision as of 04:20, 11 December 2024
import os import sys from threading import Event from PyHotKey import Key, keyboard keyboard.suppress_hotkey = True from tkinter import *
scriptFolder = (os.path.dirname(__file__))
clipboardBuffer = [] clipboardBuffer = ["No value in this clipboard buffer" for i in range(10)]
def inputbox(inputBuffer): inputText = "No Input Given Yet" master = Tk() textbox = Entry(master) textbox.pack() textbox.focus_set()
def onclick(pos): nonlocal inputText inputText = textbox.get() global clipboardBuffer clipboardBuffer[inputBuffer] = inputText print(f"Clipboard buffer {inputBuffer} was set to: {inputText}") master.destroy()
b = Button(master, text="OK", width=10, command=onclick) b.pack() textbox.bind('<Return>', onclick) mainloop() print(clipboardBuffer) return (inputText)
def typeBuffer(inputBuffer): keyboard.type("\b"+clipboardBuffer[inputBuffer])
#Hotkeys go here!!# for x in [1,2,3,4,5,6,7,8,9]: keyboard.register_hotkey([Key.cmd, Key.shift, str(x)], None, inputbox, x) #windows key + 1,2,3,4,5,6,7,8,9,etc keyboard.register_hotkey([Key.cmd, str(x)], None, typeBuffer, x) #windows key + 1,2,3,4,5,6,7,8,9,etc [1] #Hotkeys go here!!#
print(keyboard.hotkeys) import threading
event = threading.Event() event.wait()