I am trying to write a replacement for Alt-TAB in Windows XP using
python Win32 extensions. I am first just trying to build a list of
all tasks that are in the taskbar; on Windows, these seem to be the
same tasks that are listed in the Alt-TAB box. I pieced together the
following code from various places:
-----------------------------------------------------------------------------
from win32gui import *
def windowEnumerationHandler(hwnd, resultList):
'''Pass to win32gui.EnumWindows() to generate list of window handle, window
text tuples.'''
if IsWindowVisible(hwnd):
txt = GetWindowText(hwnd)
if (len(txt) > 0):
resultList.append((hwnd, GetWindowText(hwnd)))
windows = []
EnumChildWindows(GetDesktopWindow(), windowEnumerationHandler, windows)
for w in windows:
print "%10s %s" % (w[0], w[1])
-----------------------------------------------------------------------------
However, when it runs, it gives me more than the active applications:
C:\home\rutt\dev\win32tasks>python tasks.py
65624 start
65628 2:45 PM
65632 Notification Area
65648 Running Applications
65652 Running Applications
1245338 C:\WINDOWS\system32\cmd.exe - python tasks.py
1508856 Emacs (Fundamental) <[EMAIL PROTECTED]> tasks.py
1115660 TaskSwitchXP
1639818 FolderView
525314 Emacs (Group) <[EMAIL PROTECTED]> *Group*
17761604 My eBay Selling: Items I'm Selling - Mozilla Firefox
1770594 XTerm akron:~/archive/papers
2884722 XTerm tg-login4:~
4850694 PostMsg
2688224 FolderView
1114280 XTerm ruttlap:~/dev/win32tasks
656324 CodeGuru: PostMsg - Post a message to any window on the desktop - Mic
rosoft Internet Explorer
2753618 Google
3408896 ActivePython 2.4 - Online Docs : Constants - Microsoft Internet Explo
rer
1050106 Google
918526 Small Values of Cool: Driving win32 GUIs with Python, part 1 - Micros
oft Internet Explorer
984590 Google
2164086 WINDOWINFO - Microsoft Internet Explorer
657032 Google
65660 Program Manager
65664 FolderView
There are a few problems with the above output:
1) The first few Windows do not look like they correspond to any task
bar entries at all.
2) "FolderView" is displayed for Windows Explorer open folders; I
would really like to have the name as it exists in the title bar
instead
Does anyone know the appropriate functions to call to narrow down
these window handles to just those that are present in the taskbar?
Thanks,
--
Benjamin Rutt
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32