Python 通过 comtypes / pywin32 调用 64 位 COM 组件,需先注册 DLL。
# 需先注册:管理员 + 64位 regsvr32 注册 x64Game-Plug.dll
# 安装:pip install comtypes (或 pywin32:win32com.client.Dispatch)
import comtypes.client
plug = comtypes.client.CreateObject("x64Game.Plug", dynamic=True)
# 收费命令先授权:plug.SetUsername("U12-XXXXXXXXXXXXXXXX")
hwnd = plug.FindWindow("", "记事本") # 空类名用 ""
print("hwnd =", hwnd)
pid = plug.GetWindowProcessId(hwnd) # 只传 hwnd,返回值直接接收
print("pid =", pid)
title = plug.GetWindowTitle(hwnd)
print("title =", title)
lst = plug.EnumTopWindow() # 无入参方法,括号里什么都不写
print("EnumTopWindow =", lst)