获取窗口句柄

import win32gui

hwnd_title = dict()


def get_all_hwnd(hwnd,tem):
if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
hwnd_title.update({hwnd: win32gui.GetWindowText(hwnd)})


win32gui.EnumWindows(get_all_hwnd,2)

for h, t in hwnd_title.items():
if t is not "":
print(([h], [t]))
posted @ 2020-11-23 11:36  日天达人  阅读(127)  评论(0编辑  收藏  举报