From 4c1c1a542d382e922bfed495a18feb67084a0f95 Mon Sep 17 00:00:00 2001 From: Mikan <72257910+Mikan-DS@users.noreply.github.com> Date: Sat, 30 Aug 2025 17:39:09 +0300 Subject: [PATCH] kind of working --- commands.json | 1 + main.py | 21 +++++++++++++++++++++ text_input.py | 3 +++ 3 files changed, 25 insertions(+) diff --git a/commands.json b/commands.json index 2a5c4ee..a19a870 100644 --- a/commands.json +++ b/commands.json @@ -3,6 +3,7 @@ "ru": { "удали слово": "backspace_word", "удали слова": "backspace_word", + "удали все": "clear_all", "очисти всё": "clear_all", "новая строка": "new_line", "точка": "period", diff --git a/main.py b/main.py index 778be8b..4d20392 100644 --- a/main.py +++ b/main.py @@ -19,6 +19,7 @@ class VoiceTextInput: self.is_active = False self.language = DEFAULT_LANGUAGE self.audio_buffer = [] + self.is_active_typing = False # Блокируем pyautogui на случай, если он заблокирован pyautogui.FAILSAFE = False @@ -101,6 +102,14 @@ class VoiceTextInput: self.change_language() return + if self.is_active_typing_command(text): + self.is_active_typing = not self.is_active_typing + print(f"Ввод текста: {"" if self.is_active_typing else "не"} активирован") + return + + if not self.is_active_typing: + return + # Проверяем, является ли текст командой action_string = self.command_handler.get_command_action(text, self.language) if action_string: @@ -140,6 +149,18 @@ class VoiceTextInput: except Exception as e: print(f"Ошибка при смене языка: {e}") + def is_active_typing_command(self, text): + change_commands = { + 'ru': ['активировать ввод', 'деактивировать ввод', 'включить ввод', 'выключить ввод', "начни печатать", "хватит печатать"], + 'en': ['start typing', 'stop typing', 'start writing', 'stop writing'] + } + + text_lower = text.lower().strip() + for lang in change_commands: + for cmd in change_commands[lang]: + if cmd == text_lower: + return True + return False if __name__ == "__main__": app = VoiceTextInput() diff --git a/text_input.py b/text_input.py index a19d5d5..45e6397 100644 --- a/text_input.py +++ b/text_input.py @@ -47,6 +47,9 @@ class TextInput: # Вставляем текст с помощью горячих клавиш (Ctrl+V) pyautogui.hotkey('ctrl', 'v') + if original_clipboard: + pyperclip.copy(original_clipboard) + except Exception as e: print(f"Ошибка при вводе через clipboard: {e}")