From 6d88c762ac62d485cae4162db124df5727069785 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, 29 May 2024 13:23:41 +0800 Subject: [PATCH] precise --- LunaTranslator/LunaTranslator/myutils/hwnd.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/LunaTranslator/LunaTranslator/myutils/hwnd.py b/LunaTranslator/LunaTranslator/myutils/hwnd.py index 2821e2b1..a06642c2 100644 --- a/LunaTranslator/LunaTranslator/myutils/hwnd.py +++ b/LunaTranslator/LunaTranslator/myutils/hwnd.py @@ -233,10 +233,9 @@ def mouseselectwindow(callback): def screenshot(x1, y1, x2, y2, hwnd=None): if hwnd: - rate = QApplication.instance().devicePixelRatio() / ( - windows.GetDpiForWindow(hwnd) / 96 - ) - x1, y1, x2, y2 = (int(_ / rate) for _ in (x1, y1, x2, y2)) + _r = QApplication.instance().devicePixelRatio() + _dpi = windows.GetDpiForWindow(hwnd) + x1, y1, x2, y2 = (int(_ * 96 / _dpi / _r) for _ in (x1, y1, x2, y2)) bs = winsharedutils.gdi_screenshot(x1, y1, x2, y2, hwnd) pixmap = QPixmap() if bs: