[1805] Simplify Window Text Call

This commit is contained in:
David Sangrey committed 2024-06-18 13:09:21 -04:00
1 parent d319dd03b5
commit c0deeeb4cf
2 files changed
+2 -10

No files matched your search

+1 -5
View File
@@ -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)
+1 -5
View File
@@ -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 ''