[python-win32] build list of all tasks like Alt-TAB box
Benjamin Rutt
rutt at bmi.osu.edu
Tue Aug 9 15:17:24 CEST 2005
Benjamin Rutt <rutt at bmi.osu.edu> writes:
> Any ideas what I might be doing wrong? FYI, I am using a older
> version of Python (2.0) and win32all (I downloaded one that went with
> the 2.0 release...Add/Remove programs shows "Python 2.0 combined Win32
> extensions"). Also using Windows XP SP2. Thanks,
I think I figured it out. It must have been a problem with my using
an older version of Python. When I installed version 2.4 of Python
and Win32all alongside version 2.0, everything started to work. I
continue to piece together the following code which seems to work,
although I do not understand all of these flags:
-----------------------------------------------------------------------------
from win32gui import *
from win32con import *
gwl_style = GWL_STYLE
def windowEnumerationHandler(hwnd, resultList):
'''Pass to win32gui.EnumWindows() to generate list of window handle, window\
text tuples.'''
if IsWindowVisible(hwnd):
val = GetWindowLong(hwnd, gwl_style)
if val & WS_VISIBLE:
if not val & WS_CHILD:
if not val & WS_EX_TOOLWINDOW:
if val & WS_EX_CONTROLPARENT:
val = GetWindowLong(hwnd, gwl_style)
txt = GetWindowText(hwnd)
resultList.append((hwnd, txt))
windows = []
EnumChildWindows(GetDesktopWindow(), windowEnumerationHandler, windows)
for w in windows:
print "%10s %s" % (w[0], w[1])
-----------------------------------------------------------------------------
Does anyone happen to know why if the window handle is not an
WS_EX_TOOLWINDOW and is an WS_EX_CONTROLPARENT, then it is one of the
taskbar programs? Thanks,
--
Benjamin Rutt
More information about the Python-win32
mailing list