diff --git a/LunaTranslator/LunaTranslator/gui/settingpage_quick.py b/LunaTranslator/LunaTranslator/gui/settingpage_quick.py index d862619e..c6854ad2 100644 --- a/LunaTranslator/LunaTranslator/gui/settingpage_quick.py +++ b/LunaTranslator/LunaTranslator/gui/settingpage_quick.py @@ -46,6 +46,7 @@ def setTab_quick_direct(self): windows.RegisterWindowMessage("Magpie_Core_CLI_Message_ToggleOverlay"), ), "_26": gobject.baseobject.translation_ui.ocr_once_signal.emit, + "_27": gobject.baseobject.translation_ui.simulate_key_enter, } for name in globalconfig["quick_setting"]["all"]: if name not in self.bindfunctions: diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 795c3c61..68b05155 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -390,15 +390,16 @@ class QUnFrameWindow(resizableframeless): rangeselct_function(self, ocroncefunction, False, False) - def addbuttons(self): - def simulate_key_enter(): - windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd) - time.sleep(0.1) - while windows.GetForegroundWindow() == gobject.baseobject.textsource.hwnd: - time.sleep(0.001) - windows.keybd_event(13, 0, 0, 0) - windows.keybd_event(13, 0, windows.KEYEVENTF_KEYUP, 0) + @threader + def simulate_key_enter(self): + windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd) + time.sleep(0.1) + while windows.GetForegroundWindow() == gobject.baseobject.textsource.hwnd: + time.sleep(0.001) + windows.keybd_event(13, 0, 0, 0) + windows.keybd_event(13, 0, windows.KEYEVENTF_KEYUP, 0) + def addbuttons(self): def simulate_key_ctrl(): windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd) time.sleep(0.1) @@ -469,7 +470,7 @@ class QUnFrameWindow(resizableframeless): ), ( "simulate_key_enter", - lambda: threading.Thread(target=simulate_key_enter).start(), + self.simulate_key_enter, ), ( "copy_once", diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index d13a9272..4cd3e483 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -571,6 +571,11 @@ "use": false, "name": "进行一次OCR", "keystring": "" + }, + "_27": { + "use": false, + "name": "模拟按键Enter", + "keystring": "" } } },