[IronPython] Shell.Application.Windows

Lacko Roman rlacko at gratex.com
Wed Jul 28 17:21:15 CEST 2010


Hi,

I have problem with following code, where call to [doc.title] failes:

# GET ALL INTERNET EXPLORER WINDOWS
app = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("Shell.Application"))
for w in app.Windows():
    try:
        print w.Type()
        # CHECK IF THIS WINDOW HOLDS HTML
        if (w.Type() == "HTML Document"):
            doc = ie.document
            # THIS WILL FAIL WITH "object <doc> has no property <title>"
            print doc.title
            break
    except Exception, e:
        print e

All I want is to get specific internet explorer window and get some info from the document

This code is working in Cpython with win32com:

app = win32com.client.Dispatch("Shell.Application")
for w in app.Windows():
    try:
        print w.Type
        if (w.Type == "HTML Document"):
            ie = w
            doc = ie.document
            print doc.title
            break
    except Exception, e:
        print e

Thanks in advance

-Roman



More information about the Ironpython-users mailing list