import sys
import ctypes
sys.path.insert(0, r"c:\Projects\AutoPOE2")
from src.common.win32_window import attach_to_default_desktop

attach_to_default_desktop()
user32 = ctypes.windll.user32
fg = 0x4d09f4

def enum_child(hwnd, lparam):
    buf = ctypes.create_unicode_buffer(512)
    user32.GetWindowTextW(hwnd, buf, 512)
    if buf.value:
        print(f"  Child: {hex(hwnd)} \"{buf.value}\"")
    return True

EnumChildProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.c_int, ctypes.c_int)
print(f"Error Dialog {hex(fg)} Children:")
user32.EnumChildWindows(fg, EnumChildProc(enum_child), 0)
