From 934e3932ffaa33d566ab85db14db9dacce8dcfed 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: Thu, 15 Aug 2024 03:22:14 +0800 Subject: [PATCH] Update ocrutil.py --- LunaTranslator/LunaTranslator/myutils/ocrutil.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LunaTranslator/LunaTranslator/myutils/ocrutil.py b/LunaTranslator/LunaTranslator/myutils/ocrutil.py index 488e1098..f4616bdc 100644 --- a/LunaTranslator/LunaTranslator/myutils/ocrutil.py +++ b/LunaTranslator/LunaTranslator/myutils/ocrutil.py @@ -62,6 +62,11 @@ def imageCut(hwnd, x1, y1, x2, y2, viscompare=True, rawimage=False) -> QImage: _x1, _y1 = windows.ScreenToClient(hwnd, x1, y1) _x2, _y2 = windows.ScreenToClient(hwnd, x2, y2) + + if not QRect(0, 0, rect[2] - rect[0], rect[3] - rect[1]).contains( + QRect(_x1, _y1, _x2 - _x1, _y2 - _y1) + ): + continue pix = screenshot(_x1, _y1, _x2, _y2, hwnd) if pix.toImage().allGray(): continue