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

res = []
def cb(h, _):
    txt_len = user32.GetWindowTextLengthW(h) + 1
    txt_buf = ctypes.create_unicode_buffer(txt_len)
    user32.GetWindowTextW(h, txt_buf, txt_len)
    cls_buf = ctypes.create_unicode_buffer(256)
    user32.GetClassNameW(h, cls_buf, 256)
    pid = wintypes.DWORD()
    user32.GetWindowThreadProcessId(h, ctypes.byref(pid))
    if any(k in txt_buf.value.lower() or k in cls_buf.value.lower() for k in ['viet', 'guard', 'sword', 'vo lam', 'game', '32770']):
        res.append((h, pid.value, cls_buf.value, txt_buf.value, user32.IsWindowVisible(h)))
    return True

WNDENUMPROC = ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)
user32.EnumWindows(WNDENUMPROC(cb), 0)
for h, pid, cls, txt, vis in res:
    print(f'{hex(h)} | PID: {pid} | {cls} | "{txt}" | Visible: {vis}')
