获取窗口句柄

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]))
原文地址:https://www.cnblogs.com/98WDJ/p/14023567.html