import win32gui
def demo_top_windows():
'''
演示如何列出所有的顶级窗口
:return:
'''
hWndList = []
win32gui.EnumWindows(lambda hWnd, param: param.append(hWnd), hWndList)
for hWnd in hWndList:
title = win32gui.GetWindowText(hWnd)
title = title.encode().decode('utf-8')
clsname = win32gui.GetClassName(hWnd)
print(hWnd,title,clsname)
# hWnd windows pid
# title 窗口标题
# clsname 窗口类名
print(hWndList)
demo_top_windows()
python获取window所有窗口信息
最新推荐文章于 2024-03-19 14:17:41 发布