From 4b1a516abd3e60a026bc118d97525b4aab6506cd 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, 14 Aug 2024 20:04:42 +0800 Subject: [PATCH] Update ocrtext.py --- LunaTranslator/LunaTranslator/textsource/ocrtext.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/LunaTranslator/LunaTranslator/textsource/ocrtext.py b/LunaTranslator/LunaTranslator/textsource/ocrtext.py index de731f31..52aa638a 100644 --- a/LunaTranslator/LunaTranslator/textsource/ocrtext.py +++ b/LunaTranslator/LunaTranslator/textsource/ocrtext.py @@ -78,7 +78,7 @@ class ocrtext(basetext): h4 = windows.WindowFromPoint(windows.POINT(p2[0], p1[1])) self.range_ui[-1].setrect(rect) - if globalconfig["multiregion"]: + if len(self.range_ui) > 1: return usehwnds = [] for _ in (h1, h2, h3, h4): @@ -89,14 +89,9 @@ class ocrtext(basetext): if not usehwnds: return hwnd, count = Counter(usehwnds).most_common()[0] - if self.hwnd: - if count == len(usehwnds): - self.hwnd = hwnd - self.pids = [windows.GetWindowThreadProcessId(hwnd)] - else: - if count >= len(usehwnds) - 1: - self.hwnd = hwnd - self.pids = [windows.GetWindowThreadProcessId(hwnd)] + if count == len(usehwnds): + self.hwnd = hwnd + self.pids = [windows.GetWindowThreadProcessId(hwnd)] def setstyle(self): [_.setstyle() for _ in self.range_ui]