diff --git a/LunaTranslator/LunaTranslator/translator/basetranslator_dev.py b/LunaTranslator/LunaTranslator/translator/basetranslator_dev.py index 400acbad..afb1e08c 100644 --- a/LunaTranslator/LunaTranslator/translator/basetranslator_dev.py +++ b/LunaTranslator/LunaTranslator/translator/basetranslator_dev.py @@ -100,7 +100,7 @@ class basetransdev(basetrans): time.sleep(0.1) def send_keys(self, text): - self._SendRequest("Input.setIgnoreInputEvents", {"ignore": False}) + #self._SendRequest("Input.setIgnoreInputEvents", {"ignore": False}) try: self._SendRequest("Input.insertText", {"text": text}) except: @@ -127,4 +127,4 @@ class basetransdev(basetrans): ) # self._SendRequest('Input.dispatchKeyEvent', {'type': 'keyUp', 'modifiers': 0, 'timestamp': 0, 'text': '', 'unmodifiedText': '', 'keyIdentifier': '', 'code': f'Key{char.upper()}', 'key': char, 'windowsVirtualKeyCode': code, 'nativeVirtualKeyCode': code, 'autoRepeat': False, 'isKeypad': False, 'isSystemKey': False, 'location': 0}) - self._SendRequest("Input.setIgnoreInputEvents", {"ignore": True}) + #self._SendRequest("Input.setIgnoreInputEvents", {"ignore": True}) diff --git a/LunaTranslator/LunaTranslator/translator/dev_yandex.py b/LunaTranslator/LunaTranslator/translator/dev_yandex.py index 29bef544..4369544f 100644 --- a/LunaTranslator/LunaTranslator/translator/dev_yandex.py +++ b/LunaTranslator/LunaTranslator/translator/dev_yandex.py @@ -4,10 +4,15 @@ from translator.basetranslator_dev import basetransdev class TS(basetransdev): target_url = "https://translate.yandex.com/" + def inittranslator(self): + self.last = "" + def translate(self, content): self.Runtime_evaluate('document.querySelector("#fakeArea").innerText=""') self.Runtime_evaluate('document.querySelector("#fakeArea").click()') self.send_keys(content) - return self.wait_for_result( - 'document.querySelector("#translation > span").innerText' + last = self.wait_for_result( + 'document.querySelector("#translation > span").innerText', self.last ) + self.last = last + return self.last