Created
May 24, 2012 06:03
-
-
Save geekman/2779738 to your computer and use it in GitHub Desktop.
list normal open windows (like Alt-Tab or Task Manager does)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32con | |
import win32gui | |
import ctypes | |
_user32 = ctypes.windll.user32 | |
excludes = (_user32.GetShellWindow(), win32gui.FindWindow('Shell_TrayWnd', None)) | |
winlist = [] | |
win32gui.EnumWindows(lambda hwnd, l: l.append(hwnd) if \ | |
win32gui.IsWindowVisible(hwnd) and \ | |
not win32gui.GetWindow(hwnd, win32con.GW_OWNER) and \ | |
hwnd not in excludes \ | |
else True, winlist) | |
# show results | |
print len(winlist) | |
for x in [(h, win32gui.GetClassName(h), win32gui.GetWindowText(h)) for h in winlist]: | |
print repr(x) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment