By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,220 Members | 1,516 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,220 IT Pros & Developers. It's quick & easy.

how to recognize IE window already opened using win32com extension

P: n/a
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.)
Jul 7 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
korean_dave 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.)
I have this strange feeling of deja vu. Is there some sort of
"opening IE windows with Python" conference going on
somewhere?

Have a look at Roger Upole's answer from the other day:

http://mail.python.org/pipermail/pyt...ne/007796.html

TJG
Jul 7 '08 #2

P: n/a
On Jul 7, 11:09*am, korean_dave <davidrey...@gmail.comwrote:
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
function:

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

resultList.append((hwnd, win32gui.GetWindowText(hwnd)))
</code>

And call it like this:

<code>
topWindows = []
win32gui.EnumWindows(self.windowEnumerationHandler , topWindows)
</code>

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

<code>
for i in topWindows:
if windowText in i[1]:
# do something
</code>

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: http://mail.python.org/mailman/listinfo/python-win32

That should get you going...hopefully

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
Jul 7 '08 #3

P: n/a
On Jul 7, 11:16*am, Tim Golden <m...@timgolden.me.ukwrote:
korean_dave 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.)

I have this strange feeling of deja vu. Is there some sort of
"opening IE windows with Python" conference going on
somewhere?

Have a look at Roger Upole's answer from the other day:

http://mail.python.org/pipermail/pyt...ne/007796.html

TJG
Crumb! That's way easier than the one I mentioned!

Mike
Jul 7 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.