I think, that it would sometimes greatly improve your workflow, if you
could ctrl + c
(copy) in a series.
That means, that when pressing ctrl +c
is pressed, the content is stored in the memory
until ctrl + v
releases all the strings in memory. (Let's assume at the beginning, I only copy strings).
I would like to use pynput
but any other solution is appreciated as well and this is how far I got:
from pynput import keyboard
current = set()
class memory_class(object):
def __init__(self):
self.memory = []
return None
def add_element(self,element):
self.memory.append(element)
def clear_memory(self):
self.memory = []
memory = memory_class()
def execute():
print("Hello ! C has been pressed.")
memory.add_element("Hello")
def on_press(key):
if any([key in COMBO for COMBO in COMBINATIONS]):
current.add(key)
if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
execute()
def on_release(key):
if any([key in COMBO for COMBO in COMBINATIONS]):
current.remove(key)
# The key combination to check
COMBINATIONS = [
{keyboard.Key.ctrl, keyboard.KeyCode(char='c')},
#{keyboard.Key.shift, keyboard.KeyCode(char='A')}
]
with keyboard.Listener(on_press = on_press, on_release = on_release) as listener:
listener.join()
- How do I access the text that is usually copied when using
ctrl + c
. The functionon_press
always only depend on the key that has been pressed. - How do I implement another method
ctrl + v
that pastes all the content from the memory and deletes it afterwards.