how to recognize IE window already opened using win32com extension

Mike Driscoll kyosohma at
Mon Jul 7 18:19:15 CEST 2008

On Jul 7, 11:09 am, korean_dave <davidrey... at> wrote:
> How do I use the win32com API to manipulate IE windows ALREADY open?
> ie = Dispatch("InternetExplorer.Application") opens a new window.
> But I'd like to be able to find, of windows already open, a specific
> window (with a specified property, matching url, etc.)

You'll probably want to re-post to the PyWin32 user's group, but in
the mean time, here's one way to go about it. I use the following

def windowEnumerationHandler(self, hwnd, resultList):
        This is a handler to be passed to win32gui.EnumWindows() to
        a list of (window handle, window text) tuples.

        resultList.append((hwnd, win32gui.GetWindowText(hwnd)))

And call it like this:

topWindows = []
win32gui.EnumWindows(self.windowEnumerationHandler, topWindows)

Then you can use a for loop to iterate over the topWindows list to
find the one with the correct title:

for i in topWindows:
    if windowText in i[1]:
        # do something

Notice that I use the win32gui module. Make sure you have the win32
modules installed or this won't work.

Here's the link to PyWin32 group:

That should get you going...hopefully

Mike Driscoll

Python Extension Building Network:

More information about the Python-list mailing list