From 434d1f1fc9085402dc5e675c51e272d86247de27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 28 Aug 2024 01:21:20 +0800 Subject: [PATCH] fix --- .../LunaTranslator/textsource/texthook.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/LunaTranslator/LunaTranslator/textsource/texthook.py b/LunaTranslator/LunaTranslator/textsource/texthook.py index 22abf10b..4ef2a5b1 100644 --- a/LunaTranslator/LunaTranslator/textsource/texthook.py +++ b/LunaTranslator/LunaTranslator/textsource/texthook.py @@ -413,7 +413,11 @@ class texthook(basetext): return string def removeproc(self, pid): - self.pids.remove(pid) + try: + if pid in self.pids: + self.pids.remove(pid) + except: + pass if len(self.pids) == 0: self.autohookmonitorthread() @@ -449,8 +453,17 @@ class texthook(basetext): "错误", "权限不足,请以管理员权限运行!" ) + @threader + def waitend(self, pid): + windows.WaitForSingleObject( + windows.AutoHandle(windows.OpenProcess(windows.SYNCHRONIZE, False, pid)), + windows.INFINITE, + ) + self.removeproc(pid) + def onprocconnect(self, pid): self.pids.append(pid) + self.waitend(pid) for hookcode in self.needinserthookcode: self.Luna_InsertHookCode(pid, hookcode) gobject.baseobject.displayinfomessage(