"Mark Hammond" <[EMAIL PROTECTED]> writes:

>> Does anyone know the appropriate functions to call to narrow down
>> these window handles to just those that are present in the taskbar?
>
> Checking the window is a "top-level" window gives a better result for me.
> ie:
>
>     if IsWindowVisible(hwnd) and not GetWindowLong(hwnd, win32con.GWL_STYLE)
> & win32con.WS_CHILD:

Thanks for the suggestion.  I do have some problem executing this kind
of code however.  The callback seems to exit early, around the call to
GetWindowLong().  The following code and output support this analysis:

-----------------------------------------------------------------------------
import win32con
from win32gui import *

gwl_style = win32con.GWL_STYLE
print 'GWL_STYLE', gwl_style
def windowEnumerationHandler(hwnd, resultList):
    '''Pass to win32gui.EnumWindows() to generate list of window handle, window 
text tuples.'''
    if IsWindowVisible(hwnd):
        print 'hi1'
        val = GetWindowLong(hwnd, gwl_style)
        print 'hi2'
        txt = GetWindowText(hwnd)
        resultList.append((hwnd, txt))
        print 'hi3'

windows = []
EnumChildWindows(GetDesktopWindow(), windowEnumerationHandler, windows)
for w in windows:
    print "%10s %s" % (w[0], w[1])
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
C:\home\rutt\dev\win32tasks>python tasks.py
GWL_STYLE -16
hi1
hi1
hi1
hi1
hi1
[...]
hi1
hi1

C:\home\rutt\dev\win32tasks>
-----------------------------------------------------------------------------

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,
-- 
Benjamin Rutt

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to