Open
Description
pyinput give the possibility to add mouse hotkey, like the side buttons. It is much convenient to use it with a thumb click. Could you elaborate it to add mouse hotkey functionality as well with pynput? It can be used next to the keyboard hotkeys.
I have done it personally to test it and works great.
Like:
from pynput import mouse
def run(self):
"""Run the recorder, setting up hotkeys and entering the main loop."""
keyboard.add_hotkey(config.RECORD_HOTKEY, self.handle_hotkey_wrapper)
keyboard.add_hotkey(config.CANCEL_HOTKEY, self.cancel_all)
keyboard.add_hotkey(config.CLEAR_HISTORY_HOTKEY, self.clear_messages)
def on_click(x, y, button, pressed):
if button == getattr(mouse.Button, config.MOUSE_CANCEL_HOTKEY) and pressed:
self.cancel_all()
elif button == getattr(mouse.Button, config.MOUSE_RECORD_HOTKEY) and pressed:
self.handle_hotkey_wrapper()
elif button == getattr(mouse.Button, config.MOUSE_CLEAR_HISTORY_HOTKEY) and pressed:
self.clear_messages()
mouse_listener = mouse.Listener(on_click=on_click)
mouse_listener.start()
print(f"Press '{config.RECORD_HOTKEY}' to start recording, press again to stop and transcribe.\nDouble tap to give the AI access to read your clipboard.\nPress '{config.CANCEL_HOTKEY}' to cancel recording.\nPress '{config.CLEAR_HISTORY_HOTKEY}' to clear the chat history.")
Or replace the keyboard as well with pynput as in a pull request suggested.
Config.py:
### HOTKEYS ###
CANCEL_HOTKEY = 'ctrl + alt + x'
CLEAR_HISTORY_HOTKEY = 'ctrl + alt + f12'
RECORD_HOTKEY = 'ctrl + shift + space'
# Mouse keys are:'x1' mouse sidebutton 1, 'x2' for mouse sidebutton 2, 'middle' for mouse middle button
MOUSE_CANCEL_HOTKEY = 'x1'
MOUSE_CLEAR_HISTORY_HOTKEY = 'middle'
MOUSE_RECORD_HOTKEY = 'x2'
Metadata
Metadata
Assignees
Labels
No labels
Activity