diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index e7ea9344..2edf3fb6 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -1090,30 +1090,6 @@ class dialog_setting_game_internal(QWidget): savehook_new_data[gameuid]["anki_DeckName"] = savehook_new_data[gameuid].get( "anki_DeckName", globalconfig["ankiconnect"]["DeckName"] ) - savehook_new_data[gameuid]["anki_simulate_key_1_use"] = savehook_new_data[ - gameuid - ].get( - "anki_simulate_key_1_use", - globalconfig["ankiconnect"]["simulate_key"]["1"]["use"], - ) - savehook_new_data[gameuid]["anki_simulate_key_1_keystring"] = savehook_new_data[ - gameuid - ].get( - "anki_simulate_key_1_keystring", - globalconfig["ankiconnect"]["simulate_key"]["1"]["keystring"], - ) - savehook_new_data[gameuid]["anki_simulate_key_2_use"] = savehook_new_data[ - gameuid - ].get( - "anki_simulate_key_2_use", - globalconfig["ankiconnect"]["simulate_key"]["2"]["use"], - ) - savehook_new_data[gameuid]["anki_simulate_key_2_keystring"] = savehook_new_data[ - gameuid - ].get( - "anki_simulate_key_2_keystring", - globalconfig["ankiconnect"]["simulate_key"]["2"]["keystring"], - ) formLayout2 = self.createfollowdefault( savehook_new_data[gameuid], "follow_default_ankisettings", formLayout @@ -1125,36 +1101,6 @@ class dialog_setting_game_internal(QWidget): "anki_DeckName", ), ) - formLayout2.addRow( - "录音时模拟按键", - getboxlayout( - [ - getsimpleswitch( - savehook_new_data[gameuid], "anki_simulate_key_1_use" - ), - getsimplekeyseq( - savehook_new_data[gameuid], "anki_simulate_key_1_keystring" - ), - ], - margin0=True, - makewidget=True, - ), - ) - formLayout2.addRow( - "录音时模拟按键_例句", - getboxlayout( - [ - getsimpleswitch( - savehook_new_data[gameuid], "anki_simulate_key_2_use" - ), - getsimplekeyseq( - savehook_new_data[gameuid], "anki_simulate_key_2_keystring" - ), - ], - margin0=True, - makewidget=True, - ), - ) def getpretranstab(self, formLayout: LFormLayout, gameuid): diff --git a/LunaTranslator/LunaTranslator/gui/setting_hotkey.py b/LunaTranslator/LunaTranslator/gui/setting_hotkey.py index 2674fe18..33aa0a48 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_hotkey.py +++ b/LunaTranslator/LunaTranslator/gui/setting_hotkey.py @@ -62,6 +62,8 @@ def registrhotkeys(self): "_28": lambda: winsharedutils.clipboard_set( gobject.baseobject.currenttranslate ), + "_29": lambda: gobject.baseobject.searchwordW.ankiwindow.recordbtn1.click(), + "_30": lambda: gobject.baseobject.searchwordW.ankiwindow.recordbtn2.click(), } for name in globalconfig["quick_setting"]["all"]: if name not in self.bindfunctions: diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index 22699794..451c7dd7 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -5,7 +5,6 @@ from traceback import print_exc import qtawesome, requests, gobject, windows import myutils.ankiconnect as anki from myutils.hwnd import grabwindow -from myutils.utils import parsekeystringtomodvkcode, unsupportkey from myutils.config import globalconfig, _TR, static_data, savehook_new_data from myutils.subproc import subproc_w from myutils.wrapper import threader, tryprint @@ -21,7 +20,6 @@ from gui.usefulwidget import ( getlineedit, listediterline, getsimpleswitch, - getsimplekeyseq, makesubtab_lazy, getIconButton, tabadd_lazy, @@ -400,82 +398,9 @@ class AnkiWindow(QWidget): getsimpleswitch(globalconfig["ankiconnect"], "fillmaksastrans"), ) - layout.addRow( - "录音时模拟按键", - getboxlayout( - [ - getsimpleswitch( - globalconfig["ankiconnect"]["simulate_key"]["1"], "use" - ), - getsimplekeyseq( - globalconfig["ankiconnect"]["simulate_key"]["1"], "keystring" - ), - ], - margin0=True, - makewidget=True, - ), - ) - layout.addRow( - "录音时模拟按键_例句", - getboxlayout( - [ - getsimpleswitch( - globalconfig["ankiconnect"]["simulate_key"]["2"], "use" - ), - getsimplekeyseq( - globalconfig["ankiconnect"]["simulate_key"]["2"], "keystring" - ), - ], - margin0=True, - makewidget=True, - ), - ) - - @threader - def simulate_key(self, i): - def __internal__keystring(i): - try: - for _ in (0,): - - if not gobject.baseobject.textsource: - break - - gameuid = gobject.baseobject.textsource.gameuid - if not gameuid: - break - if savehook_new_data[gameuid]["follow_default_ankisettings"]: - break - if not savehook_new_data[gameuid][f"anki_simulate_key_{i}_use"]: - return None - return savehook_new_data[gameuid][ - f"anki_simulate_key_{i}_keystring" - ] - except: - pass - return globalconfig["ankiconnect"]["simulate_key"][i]["keystring"] - - keystring = __internal__keystring(i) - if not keystring: - return - windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd) - time.sleep(0.1) - try: - modes, vkcode = parsekeystringtomodvkcode(keystring, modes=True) - except unsupportkey as e: - print("不支持的键") - return - for mode in modes: - windows.keybd_event(mode, 0, 0, 0) - windows.keybd_event(vkcode, 0, 0, 0) - time.sleep(0.1) - windows.keybd_event(vkcode, 0, windows.KEYEVENTF_KEYUP, 0) - for mode in modes: - windows.keybd_event(mode, 0, windows.KEYEVENTF_KEYUP, 0) - def startorendrecord(self, i, target: QLineEdit, idx): if idx == 1: self.recorder = loopbackrecorder() - self.simulate_key(i) else: self.recorder.end(callback=target.setText) @@ -519,6 +444,8 @@ class AnkiWindow(QWidget): recordbtn2.statuschanged1.connect( functools.partial(self.startorendrecord, "2", self.audiopath_sentence) ) + self.recordbtn1 = recordbtn1 + self.recordbtn2 = recordbtn2 layout.addLayout( getboxlayout( [ diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 00230ac4..090c5f7e 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -478,16 +478,6 @@ "ocrcroped": false, "autoruntts": false, "autoruntts2": false, - "simulate_key": { - "1": { - "use": false, - "keystring": "" - }, - "2": { - "use": false, - "keystring": "" - } - }, "autocrop": false, "addsuccautoclose": false, "boldword": false, @@ -1004,6 +994,16 @@ "use": false, "name": "复制到剪贴板_翻译", "keystring": "" + }, + "_29": { + "use": false, + "name": "Anki_录音", + "keystring": "" + }, + "_30": { + "use": false, + "name": "Anki_录音_例句", + "keystring": "" } } }, diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index b1ad92f1..3a510381 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -667,7 +667,6 @@ "优先级": "الأولوية", "编码": "ترميز", "自动TTS": "التلقائي تحويل النص إلى كلام", - "录音时模拟按键": "التناظرية مفتاح التسجيل", "窗口截图": "نافذة لقطة", "自动截图": "لقطة التلقائي", "模糊匹配": "غامض مطابقة", @@ -829,5 +828,6 @@ "下": "تحت", "右": "حق .", "上": "أعلى", - "左": "يسار ." + "左": "يسار .", + "录音": "تسجيل صوتي" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index f7baf49d..0e81fe78 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -667,7 +667,6 @@ "优先级": "優先順序", "编码": "編碼", "自动TTS": "自動 TTS", - "录音时模拟按键": "錄音時模擬按鍵", "窗口截图": "視窗截圖", "自动截图": "自動截圖", "模糊匹配": "模糊匹配", @@ -829,5 +828,6 @@ "下": "下", "右": "右", "上": "上", - "左": "左" + "左": "左", + "录音": "錄音" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index 8f67625a..6bc630d6 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -666,7 +666,6 @@ "优先级": "Priority", "编码": "Encoding", "自动TTS": "Auto TTS", - "录音时模拟按键": "Simulate Key Press During Recording", "窗口截图": "Window Screenshot", "自动截图": "Auto Screenshot", "模糊匹配": "Fuzzy Matching", @@ -829,5 +828,6 @@ "下": "lower", "右": "right", "上": "upper", - "左": "Left" + "左": "Left", + "录音": "sound recording" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index a1e8c0b6..fd1662c7 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -667,7 +667,6 @@ "优先级": "Prioridad", "编码": "Codificación", "自动TTS": "TTS automático", - "录音时模拟按键": "Teclas de simulación durante la grabación", "窗口截图": "Captura de pantalla de la ventana", "自动截图": "Captura de pantalla automática", "模糊匹配": "Coincidencia inútil", @@ -829,5 +828,6 @@ "下": "Abajo", "右": "Derecha", "上": "Arriba", - "左": "Izquierda" + "左": "Izquierda", + "录音": "Grabación" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index b466853b..6d4e5f3c 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -667,7 +667,6 @@ "优先级": "Priorité", "编码": "Codage", "自动TTS": "Tts automatique", - "录音时模拟按键": "Simulation des touches lors de l'enregistrement", "窗口截图": "Capture d'écran de la fenêtre", "自动截图": "Capture d'écran automatique", "模糊匹配": "Correspondance floue", @@ -829,5 +828,6 @@ "下": "En bas", "右": "Droite", "上": "En haut", - "左": "Gauche" + "左": "Gauche", + "录音": "Enregistrement sonore" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index 713a41c9..0f08d4fc 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -667,7 +667,6 @@ "优先级": "priorità", "编码": "codifica", "自动TTS": "TTS automatico", - "录音时模拟按键": "Simula pulsanti durante la registrazione", "窗口截图": "Schermata finestra", "自动截图": "Schermata automatica", "模糊匹配": "Corrispondenza sfocata", @@ -829,5 +828,6 @@ "下": "inferiore", "右": "destra", "上": "superiore", - "左": "Sinistra" + "左": "Sinistra", + "录音": "registrazione audio" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index 6dd40e49..80c1f0f5 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -667,7 +667,6 @@ "优先级": "優先度", "编码": "エンコード", "自动TTS": "自動TTS", - "录音时模拟按键": "録音時アナログボタン", "窗口截图": "ウィンドウのスクリーンショット", "自动截图": "自動スクリーンショット", "模糊匹配": "ファジィマッチング", @@ -829,5 +828,6 @@ "下": "下", "右": "右揃え", "上": "上へ", - "左": "左揃え" + "左": "左揃え", + "录音": "レコーディング" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index 1ac35eae..d63d7a77 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -667,7 +667,6 @@ "优先级": "우선 순위", "编码": "인코딩", "自动TTS": "자동 TTS", - "录音时模拟按键": "녹음 시 시뮬레이션 키", "窗口截图": "창 캡처", "自动截图": "자동 캡처", "模糊匹配": "흐림 일치", @@ -829,5 +828,6 @@ "下": "하", "右": "오른쪽", "上": "위", - "左": "왼쪽" + "左": "왼쪽", + "录音": "녹음" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index c0693dbe..b2faf838 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -667,7 +667,6 @@ "优先级": "priorytet", "编码": "kodowanie", "自动TTS": "Automatyczny TTS", - "录音时模拟按键": "Symulowanie przycisków podczas nagrywania", "窗口截图": "Zrzut ekranu okna", "自动截图": "Automatyczny zrzut ekranu", "模糊匹配": "Dopasowanie rozmyte", @@ -829,5 +828,6 @@ "下": "niżej", "右": "w prawo", "上": "górna", - "左": "Lewa" + "左": "Lewa", + "录音": "nagrywanie dźwięku" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index 84e11355..ecd47940 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -667,7 +667,6 @@ "优先级": "Приоритеты", "编码": "Код", "自动TTS": "Автоматический TTS", - "录音时模拟按键": "Клавиша моделирования при записи", "窗口截图": "Снимок окна", "自动截图": "Автоматический снимок экрана", "模糊匹配": "Нечеткое согласование", @@ -829,5 +828,6 @@ "下": "А", "右": "Правый", "上": "Вперед!", - "左": "Левый" + "左": "Левый", + "录音": "Запись" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index 3b396402..3ce933d2 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -667,7 +667,6 @@ "优先级": "ลำดับความสำคัญ", "编码": "การเข้ารหัส", "自动TTS": "TTS อัตโนมัติ", - "录音时模拟按键": "การจำลองปุ่มกดเมื่อบันทึก", "窗口截图": "ภาพหน้าจอของหน้าต่าง", "自动截图": "ภาพหน้าจออัตโนมัติ", "模糊匹配": "จับคู่เบลอ", @@ -829,5 +828,6 @@ "下": "ลง", "右": "ขวา", "上": "บน", - "左": "ซ้าย" + "左": "ซ้าย", + "录音": "การบันทึกเสียง" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index fbe8fba5..569ee879 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -667,7 +667,6 @@ "优先级": "Prioritet", "编码": "coding", "自动TTS": "Otomatik TTS", - "录音时模拟按键": "Kaydedirken düğmeleri simüle edin", "窗口截图": "Window screenshot", "自动截图": "Otomatik ekran fotoğrafı", "模糊匹配": "Çılgın eşleşme", @@ -829,5 +828,6 @@ "下": "aşağı", "右": "sağ", "上": "üst", - "左": "Sol" + "左": "Sol", + "录音": "Ses kaydedici" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index 3897767f..860c5b3c 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -667,7 +667,6 @@ "优先级": "пріоритет", "编码": "кодування", "自动TTS": "Автоматичний TTS", - "录音时模拟按键": "Імітувати кнопки під час запису", "窗口截图": "Знімок вікна", "自动截图": "Автоматичний знімок екрана", "模糊匹配": "Незрозуміле збігання", @@ -829,5 +828,6 @@ "下": "нижче", "右": "праворуч", "上": "верхній", - "左": "Ліворуч" + "左": "Ліворуч", + "录音": "звуковий запис" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index cbc4fcb0..5772d4f9 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -667,7 +667,6 @@ "优先级": "Ưu tiên", "编码": "Mã hóa", "自动TTS": "Tự động TTS", - "录音时模拟按键": "Mô phỏng các phím khi ghi âm", "窗口截图": "Ảnh chụp cửa sổ", "自动截图": "Ảnh chụp màn hình tự động", "模糊匹配": "Phù hợp mờ", @@ -829,5 +828,6 @@ "下": "Dưới", "右": "Phải", "上": "Trên", - "左": "Trái" + "左": "Trái", + "录音": "Ghi âm" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index 9f56b442..c1abee26 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -676,7 +676,6 @@ "优先级": "", "编码": "", "自动TTS": "", - "录音时模拟按键": "", "前景窗口截屏": "", "自动截图": "", "模糊匹配": "", @@ -829,5 +828,6 @@ "下": "", "右": "", "上": "", - "左": "" + "左": "", + "录音": "" } \ No newline at end of file