INNER CODE UNIT · Python
get_window_info
Qwejay/Qflow · main.py:283
def get_window_info(hwnd, pid_map=None):
if not hwnd: return None
length = user32.GetWindowTextLengthW(hwnd)
title = ""
if length > 0:
bytes_buffer = ctypes.create_unicode_buffer(length + 1)
user32.GetWindowTextW(hwnd, bytes_buffer, length + 1)
title = bytes_buffer.value
cls_buff = ctypes.create_unicode_buffer(256)
user32.GetClassNameW(hwnd, cls_buff, 256)
class_name = cls_buff.value
pid = ctypes.c_ulong()
user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
exe_name = pid_map.get(pid.value, "") if pid_map else ""
return {'hwnd': hwnd, 'title': title, 'class_name': class_name, 'exe_name': exe_name, 'pid': pid.value}
@staticmethod
def get_window_rect(hwnd):