Automating IE 6.0

Discussion in 'Python' started by EricP, Oct 25, 2003.

  1. EricP

    EricP Guest

    I'm trying to figure out how to print from IE 6.0 using Python's Win32all
    com library.
    When I do

    from win32com.client import Dispatch
    from time import sleep
    ie = Dispatch("InternetExplorer.Application")
    ie.Visible = 1
    ie.Navigate("http://www.cnn.com")
    if ie.Busy:
    sleep(2)

    and then interactly look for methods by using the ie. (dot) approach there
    are very few objects and non that relate to the tool bar or commands. How
    do I expose the IE object library and which object library do I inspect to
    see the objects and methods avaiable to me.

    Thanks
     
    EricP, Oct 25, 2003
    #1
    1. Advertising

  2. EricP

    Peter Hansen Guest

    EricP wrote:
    >
    > I'm trying to figure out how to print from IE 6.0 using Python's Win32all
    > com library.
    > When I do
    >
    > from win32com.client import Dispatch
    > from time import sleep
    > ie = Dispatch("InternetExplorer.Application")
    > ie.Visible = 1
    > ie.Navigate("http://www.cnn.com")
    > if ie.Busy:
    > sleep(2)
    >
    > and then interactly look for methods by using the ie. (dot) approach there
    > are very few objects and non that relate to the tool bar or commands. How
    > do I expose the IE object library and which object library do I inspect to
    > see the objects and methods avaiable to me.


    This isn't really a Python question, although someone might have examples
    that already work.

    Usually you need to go to the MSDN (MS Developer Network) pages and
    read up on the IE object model there.

    Do let us know if you find the answer, though, so it can be found in
    the mailing list archives.

    -Peter
     
    Peter Hansen, Oct 25, 2003
    #2
    1. Advertising

  3. EricP

    EricP Guest

    Okay I'm making some progress using win32com and com automation to get
    Internet Explorer to print from python.

    I used the makepy utility on the "Microsoft Internet Controls (1.1)" object
    library to get early binding and the following works

    # IE COM Example

    # print without prompting the user with printer dialog

    from win32com.client import Dispatch

    from time import sleep

    ie = Dispatch("InternetExplorer.Application")

    ie.Visible = 1

    ie.Navigate("http://www.cnn.com")

    if ie.Busy:

    sleep(2)

    # print the current IE document without prompting the user for the printer
    dialog

    ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,win32com.client.constants
    ..OLECMDEXECOPT_DONTPROMPTUSER)


    Next is to try to get some control over the printer properties and the
    default printer so I can write to a PDF file using Distiller.



    I'm new to python and to com objects but not to programming. This has been
    pretty painful but I got it. The pain most mostly in just finding the
    documentation for ExecWB on the microsoft site, recongnizing that the first
    attribute for ExecWB is not needed for python (assuming this is self),
    getting the constants syntax just right and 1st and foremost figuring out
    which object library to run makepy on. I've learned a lot on the way......



    "Peter Hansen" <> wrote in message
    news:...
    > EricP wrote:
    > >
    > > I'm trying to figure out how to print from IE 6.0 using Python's

    Win32all
    > > com library.
    > > When I do
    > >
    > > from win32com.client import Dispatch
    > > from time import sleep
    > > ie = Dispatch("InternetExplorer.Application")
    > > ie.Visible = 1
    > > ie.Navigate("http://www.cnn.com")
    > > if ie.Busy:
    > > sleep(2)
    > >
    > > and then interactly look for methods by using the ie. (dot) approach

    there
    > > are very few objects and non that relate to the tool bar or commands.

    How
    > > do I expose the IE object library and which object library do I inspect

    to
    > > see the objects and methods avaiable to me.

    >
    > This isn't really a Python question, although someone might have examples
    > that already work.
    >
    > Usually you need to go to the MSDN (MS Developer Network) pages and
    > read up on the IE object model there.
    >
    > Do let us know if you find the answer, though, so it can be found in
    > the mailing list archives.
    >
    > -Peter
     
    EricP, Oct 25, 2003
    #3
  4. EricP

    EricP Guest

    Sorry about the last post and the bad formmatting. I'm using outlook to
    post to the news groups and it does funky things....... Hopefully this is
    better.

    Okay I'm making some progress using win32com and com automation to get
    Microsoft Internet Controls Internet Explorer to print from python.

    I used the makepy utility on the "Microsoft Internet Controls (1.1)" object
    library to get early binding.

    This works:

    # IE COM Example
    # print without prompting the user with printer dialog

    from win32com.client import Dispatch
    from time import sleep
    ie = Dispatch("InternetExplorer.Application")
    ie.Visible = 1
    ie.Navigate("http://www.cnn.com")
    if ie.Busy:
    sleep(2)
    # print the current IE document without prompting the user for the
    printerdialog
    ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,win32com.client.constants
    ..OLECMDEXECOPT_DONTPROMPTUSER)


    Figuring out that "Microsoft Internet Controls (1.1)" was the correct object
    library for Internet Explorer was bit of a challenge. Yes of course I
    couild have guessed but then I would not have learned so much.

    What I did was:
    1) I knew that InternetExplorer.Application could be used ad the ProgID so I
    searched the registery for this text
    2) When I found the registry listing that had the associated CLSID I then
    searched the registry for this value
    3) Volia' - Found this text <strong>Microsoft Internet Controls</strong> in
    one of the registry data fields
    Next is to try to get some control over the printer properties and the
    default printer so I can write to a PDF file using Distiller.

    "EricP" <> wrote in message
    news:hgBmb.13761$9E1.66547@attbi_s52...
    > Okay I'm making some progress using win32com and com automation to get
    > Internet Explorer to print from python.
    >
    > I used the makepy utility on the "Microsoft Internet Controls (1.1)"

    object
    > library to get early binding and the following works
    >
    > # IE COM Example
    >
    > # print without prompting the user with printer dialog
    >
    > from win32com.client import Dispatch
    >
    > from time import sleep
    >
    > ie = Dispatch("InternetExplorer.Application")
    >
    > ie.Visible = 1
    >
    > ie.Navigate("http://www.cnn.com")
    >
    > if ie.Busy:
    >
    > sleep(2)
    >
    > # print the current IE document without prompting the user for the printer
    > dialog
    >
    >

    ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,win32com.client.constants
    > .OLECMDEXECOPT_DONTPROMPTUSER)
    >
    >
    > Next is to try to get some control over the printer properties and the
    > default printer so I can write to a PDF file using Distiller.
    >
    >
    >
    > I'm new to python and to com objects but not to programming. This has been
    > pretty painful but I got it. The pain most mostly in just finding the
    > documentation for ExecWB on the microsoft site, recongnizing that the

    first
    > attribute for ExecWB is not needed for python (assuming this is self),
    > getting the constants syntax just right and 1st and foremost figuring out
    > which object library to run makepy on. I've learned a lot on the way......
    >
    >
    >
    > "Peter Hansen" <> wrote in message
    > news:...
    > > EricP wrote:
    > > >
    > > > I'm trying to figure out how to print from IE 6.0 using Python's

    > Win32all
    > > > com library.
    > > > When I do
    > > >
    > > > from win32com.client import Dispatch
    > > > from time import sleep
    > > > ie = Dispatch("InternetExplorer.Application")
    > > > ie.Visible = 1
    > > > ie.Navigate("http://www.cnn.com")
    > > > if ie.Busy:
    > > > sleep(2)
    > > >
    > > > and then interactly look for methods by using the ie. (dot) approach

    > there
    > > > are very few objects and non that relate to the tool bar or commands.

    > How
    > > > do I expose the IE object library and which object library do I

    inspect
    > to
    > > > see the objects and methods avaiable to me.

    > >
    > > This isn't really a Python question, although someone might have

    examples
    > > that already work.
    > >
    > > Usually you need to go to the MSDN (MS Developer Network) pages and
    > > read up on the IE object model there.
    > >
    > > Do let us know if you find the answer, though, so it can be found in
    > > the mailing list archives.
    > >
    > > -Peter

    >
    >
     
    EricP, Oct 26, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Domino

    Automating Word

    Domino, Dec 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    427
    Domino
    Dec 8, 2003
  2. Mills
    Replies:
    0
    Views:
    4,641
    Mills
    Jun 14, 2004
  3. Matthew MacDonald

    Automating Outlook 2000

    Matthew MacDonald, Aug 31, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    508
    Matthew MacDonald
    Oct 11, 2004
  4. Smithers

    Automating Image/Button Creation

    Smithers, May 16, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,567
    Steve C. Orr [MVP, MCSD]
    May 16, 2005
  5. =?Utf-8?B?V2ViIERldmVsb3Blcg==?=

    Automating Web Farm Deployment - File Replication

    =?Utf-8?B?V2ViIERldmVsb3Blcg==?=, Jul 18, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    631
    =?Utf-8?B?V2ViIERldmVsb3Blcg==?=
    Jul 18, 2005
Loading...

Share This Page