import ctypes
import win32gui

user32 = ctypes.windll.user32
hdesk = user32.OpenInputDesktop(0, False, 0x01FF)
if hdesk: user32.SetThreadDesktop(hdesk)

hwnds = [0xd0cec, 0xe207f6, 0x2f0bf4, 0x60b66]
with open(r'c:\Projects\JX\logs\child_windows_info.txt', 'w', encoding='utf-8') as f:
    for h in hwnds:
        if user32.IsWindow(h):
            children = []
            win32gui.EnumChildWindows(h, lambda c, l: children.append((hex(c), win32gui.GetClassName(c), win32gui.GetWindowText(c))), None)
            f.write(f'HWND {hex(h)} children ({len(children)}): {children}\n')
