import win32gui
import win32process
import ctypes
import sys

sys.stdout.reconfigure(encoding='utf-8')
user32 = ctypes.windll.user32
hdesk = user32.OpenInputDesktop(0, False, 0x01FF)
if hdesk: user32.SetThreadDesktop(hdesk)

hwnds = []
def cb(h, _):
    _, pid = win32process.GetWindowThreadProcessId(h)
    if pid in [38488, 35076]:
        txt = win32gui.GetWindowText(h)
        cls = win32gui.GetClassName(h)
        vis = win32gui.IsWindowVisible(h)
        print(f"PID: {pid} | HWND: {hex(h)} | Vis: {vis} | Class: {cls} | Text: '{txt}'")
    return True

win32gui.EnumWindows(cb, 0)
