This commit is contained in:
恍兮惚兮 2024-07-25 13:09:08 +08:00
parent f9922df95e
commit f28d19291c
19 changed files with 44 additions and 169 deletions

View File

@ -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):

View File

@ -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:

View File

@ -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(
[

View File

@ -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": ""
}
}
},

View File

@ -667,7 +667,6 @@
"优先级": "الأولوية",
"编码": "ترميز",
"自动TTS": "التلقائي تحويل النص إلى كلام",
"录音时模拟按键": "التناظرية مفتاح التسجيل",
"窗口截图": "نافذة لقطة",
"自动截图": "لقطة التلقائي",
"模糊匹配": "غامض مطابقة",
@ -829,5 +828,6 @@
"下": "تحت",
"右": "حق .",
"上": "أعلى",
"左": "يسار ."
"左": "يسار .",
"录音": "تسجيل صوتي"
}

View File

@ -667,7 +667,6 @@
"优先级": "優先順序",
"编码": "編碼",
"自动TTS": "自動 TTS",
"录音时模拟按键": "錄音時模擬按鍵",
"窗口截图": "視窗截圖",
"自动截图": "自動截圖",
"模糊匹配": "模糊匹配",
@ -829,5 +828,6 @@
"下": "下",
"右": "右",
"上": "上",
"左": "左"
"左": "左",
"录音": "錄音"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -667,7 +667,6 @@
"优先级": "優先度",
"编码": "エンコード",
"自动TTS": "自動TTS",
"录音时模拟按键": "録音時アナログボタン",
"窗口截图": "ウィンドウのスクリーンショット",
"自动截图": "自動スクリーンショット",
"模糊匹配": "ファジィマッチング",
@ -829,5 +828,6 @@
"下": "下",
"右": "右揃え",
"上": "上へ",
"左": "左揃え"
"左": "左揃え",
"录音": "レコーディング"
}

View File

@ -667,7 +667,6 @@
"优先级": "우선 순위",
"编码": "인코딩",
"自动TTS": "자동 TTS",
"录音时模拟按键": "녹음 시 시뮬레이션 키",
"窗口截图": "창 캡처",
"自动截图": "자동 캡처",
"模糊匹配": "흐림 일치",
@ -829,5 +828,6 @@
"下": "하",
"右": "오른쪽",
"上": "위",
"左": "왼쪽"
"左": "왼쪽",
"录音": "녹음"
}

View File

@ -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"
}

View File

@ -667,7 +667,6 @@
"优先级": "Приоритеты",
"编码": "Код",
"自动TTS": "Автоматический TTS",
"录音时模拟按键": "Клавиша моделирования при записи",
"窗口截图": "Снимок окна",
"自动截图": "Автоматический снимок экрана",
"模糊匹配": "Нечеткое согласование",
@ -829,5 +828,6 @@
"下": "А",
"右": "Правый",
"上": "Вперед!",
"左": "Левый"
"左": "Левый",
"录音": "Запись"
}

View File

@ -667,7 +667,6 @@
"优先级": "ลำดับความสำคัญ",
"编码": "การเข้ารหัส",
"自动TTS": "TTS อัตโนมัติ",
"录音时模拟按键": "การจำลองปุ่มกดเมื่อบันทึก",
"窗口截图": "ภาพหน้าจอของหน้าต่าง",
"自动截图": "ภาพหน้าจออัตโนมัติ",
"模糊匹配": "จับคู่เบลอ",
@ -829,5 +828,6 @@
"下": "ลง",
"右": "ขวา",
"上": "บน",
"左": "ซ้าย"
"左": "ซ้าย",
"录音": "การบันทึกเสียง"
}

View File

@ -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"
}

View File

@ -667,7 +667,6 @@
"优先级": "пріоритет",
"编码": "кодування",
"自动TTS": "Автоматичний TTS",
"录音时模拟按键": "Імітувати кнопки під час запису",
"窗口截图": "Знімок вікна",
"自动截图": "Автоматичний знімок екрана",
"模糊匹配": "Незрозуміле збігання",
@ -829,5 +828,6 @@
"下": "нижче",
"右": "праворуч",
"上": "верхній",
"左": "Ліворуч"
"左": "Ліворуч",
"录音": "звуковий запис"
}

View File

@ -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"
}

View File

@ -676,7 +676,6 @@
"优先级": "",
"编码": "",
"自动TTS": "",
"录音时模拟按键": "",
"前景窗口截屏": "",
"自动截图": "",
"模糊匹配": "",
@ -829,5 +828,6 @@
"下": "",
"右": "",
"上": "",
"左": ""
"左": "",
"录音": ""
}