pip install pywin32 -i https://pypi.tuna.tsinghua.edu.cn/simple
import win32gui
hwnd_title = dict()
# and win32gui.IswindowVisible(hwnd)
def get_all_hwnd(hwnd, mouse):
if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(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)
left, top, right, bottom = win32gui.GetWindowRect(h)
width = right - left
height = bottom - top
print('left: %s, top: %s, width: %s, height: %s' % (left, top, width, height))