Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/pygetwindow/_pygetwindow_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,12 @@ def title(self):
"""Returns the window title as a string."""
textLenInCharacters = ctypes.windll.user32.GetWindowTextLengthW(self._hWnd)
stringBuffer = ctypes.create_unicode_buffer(textLenInCharacters + 1) # +1 for the \0 at the end of the null-terminated string.
ctypes.windll.kernel32.SetLastError(0)
ctypes.windll.user32.GetWindowTextW(self._hWnd, stringBuffer, textLenInCharacters + 1)

# TODO it's ambiguous if an error happened or the title text is just empty. Look into this later.
return stringBuffer.value
if ctypes.windll.kernel32.GetLastError() != 0:
_raiseWithLastError()
else:
return stringBuffer.value

@property
def visible(self):
Expand Down