def get_window_text(hwnd):
"""
Wrapper over the GetWindowTextW() Win32 function
Raises a OSError exception on error.
"""
length = ctypes.windll.user32.GetWindowTextLengthW(hwnd)
buff = ctypes.create_unicode_buffer(length + 1)
ctypes.windll.kernel32.SetLastError(0)
res = ctypes.windll.user32.GetWindowTextW(hwnd, buff, length + 1)
if not res and ctypes.GetLastError() != 0:
raise ctypes.WinError()
return buff.value
评论列表
文章目录