這還沒有任何邏輯決定是否窗戶被覆蓋,但它確實返回現有窗口的字典,他們的頭銜,可見,最小化,規模信息,並在下一個窗口句柄。
import win32gui
import win32con
def enum_handler(hwnd, results):
results[hwnd] = {
"title":win32gui.GetWindowText(hwnd),
"visible":win32gui.IsWindowVisible(hwnd),
"minimized":win32gui.IsIconic(hwnd),
"rectangle":win32gui.GetWindowRect(hwnd), #(left, top, right, bottom)
"next":win32gui.GetWindow(hwnd, win32con.GW_HWNDNEXT) # Window handle to below window
}
def get_windows():
enumerated_windows = {}
win32gui.EnumWindows(enum_handler, enumerated_windows)
return enumerated_windows
if __name__ == "__main__":
windows = get_windows()
for window_handle in windows:
if windows[window_handle]["title"] is not "":
print "{}, {}, {}, {}".format(windows[window_handle]["minimized"],
windows[window_handle]["rectangle"],
windows[window_handle]["next"],
windows[window_handle]["title"])
微軟MSDN具有良好的條每頁上GetWindow()和GW_HWNDNEXT https://msdn.microsoft.com/en-us/library/windows/desktop/ms633515(v=vs.85).aspx
ZORDER信息