#显示所有窗口的句柄和标题
# -*- coding: utf-8 -*-
"""
Created on Sun May 9 15:34:49 2021
@author: Administrator
"""
import win32gui
hwnd_title = {}
def get_all_hwnd(hwnd, mouse):
if (win32gui.IsWindow(hwnd)
and win32gui.IsWindowEnabled(hwnd)
and win32gui.IsWindowVisible(hwnd)):
hwnd_title.update({hwnd: win32gui.GetWindowText(hwnd)})
win32gui.EnumWindows(get_all_hwnd, 0)
for h, t in hwnd_title.items():
if t :
print (h, t.encode('utf-8').decode('utf-8'))
if __name__ == '__main__':
pass