From d4b29dabcf70bbbc1e2d9b577636bb87835af184 Mon Sep 17 00:00:00 2001 From: GobeX <59582195+AndrejGobeX@users.noreply.github.com> Date: Fri, 1 Dec 2023 12:56:17 +0100 Subject: [PATCH] Add scale support to window.py Added fix for scaled desktops. When Windows is scaled in the display settings, the script won't detect the edges of the Trackmania window properly. This fix makes the script makes the process DPI aware and can work under scaled environments. --- tmrl/custom/utils/window.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tmrl/custom/utils/window.py b/tmrl/custom/utils/window.py index 80241c8e..25f1fba6 100644 --- a/tmrl/custom/utils/window.py +++ b/tmrl/custom/utils/window.py @@ -7,12 +7,16 @@ import win32ui import win32con import tmrl.config.config_constants as cfg + import ctypes class WindowInterface: def __init__(self, window_name="Trackmania"): self.window_name = window_name + user32 = ctypes.windll.user32 + user32.SetProcessDPIAware() + hwnd = win32gui.FindWindow(None, self.window_name) assert hwnd != 0, f"Could not find a window named {self.window_name}."