From c0deeeb4cfdd0bccd23216647e7e13d8a08bbc60 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Tue, 18 Jun 2024 13:09:21 -0400 Subject: [PATCH] [1805] Simplify Window Text Call --- EDMarketConnector.py | 6 +----- hotkey/windows.py | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index ecc84e1b..86446218 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -272,11 +272,7 @@ if __name__ == '__main__': # noqa: C901 def window_title(h: int) -> str | None: if h: - text_length = win32gui.GetWindowTextLength(h) + 1 - buf = create_unicode_buffer(text_length) - if win32gui.GetWindowText(h): - return buf.value - + return win32gui.GetWindowText(h) return None @WINFUNCTYPE(BOOL, HWND, LPARAM) diff --git a/hotkey/windows.py b/hotkey/windows.py index 95b1a83a..ddccc333 100644 --- a/hotkey/windows.py +++ b/hotkey/windows.py @@ -47,11 +47,7 @@ def window_title(h) -> str: :return: Window title. """ if h: - title_length = win32gui.GetWindowTextLength(h) + 1 - buf = ctypes.create_unicode_buffer(title_length) - if win32gui.GetWindowText(h): - return buf.value - + return win32gui.GetWindowText(h) return ''