separate IE instances?

J Correia correiajREMOVECAPS at
Mon Jun 13 17:46:50 CEST 2005

<erinhouston at> wrote in message
news:1118671935.537464.150380 at
> Sorry about that I had an instance of ie running in the background that
> was version 0  didn't see the problem tell this morining when my
> computer started to not work.  it should be hwnds[1] should be
> hwnds[0].  I woud enumerate them like in the code below.
> If you have ie as your default browser you can use a
> shellExecute(0,None,"some url here", None, None, 1)
> To open directley to that page.
> Here is a more complete script:
> import win32api, time
> from win32com.client import Dispatch
> a = win32api.ShellExecute(0,None,"iexplore.exe",
> "",None,1)
> b = win32api.ShellExecute(0,None,"iexplore.exe",
> "",None,1)
> internetExplorerClassIdentity='{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'
> hwnds = Dispatch(internetExplorerClassIdentity)
> # way I showed you before dosn't work verry well if more then one ie is
> open
> #ieObj = hwnds[0]
> #ieObj.Navigate("")
> time.sleep(30)
> for i in range(hwnds.Count):
> ....if hwnds[i].LocationURL.lower().find("ishpeck") > -1:
> ........ieObj1 = hwnds[i]
> ....if hwnds[i].LocationURL.lower().find("google") > -1:
> ........ieObj2 = hwnds[i]
> ieObj1.Navigate("")

The thing to note is that hwnds brings back a list of all Internet Explorer
 objects running on your machine.  This *includes* things that might
not be obvious at first, like a simple Windows Explorer window
(or windows) you have running (since it uses IE in the background).
Printing hwnds.LocationName and hwnds.LocationURL in a loop
will show you exactly what processes are using IE at the time you run it.
Given that the returned list will vary each time you run your program
you'll definitely have to iterate through each hwnds item and check
if it is the browser session you want as shown in the above code.


More information about the Python-list mailing list