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)})
e = win32gui.EnumWindows(get_all_hwnd, 0)
for window_handle, window_name in hwnd_title.items():
if window_name == '此电脑':
print(window_handle)
for window_handle, window_name in hwnd_title.items():
if window_name:
print(window_handle)
if __name__ == '__main__':
pass