Automating IE 6.0

EricP fordphoto2020NOSPAM at yahoo.comNOSPAM
Sat Oct 25 16:43:57 EDT 2003


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" <peter at engcorp.com> wrote in message
news:3F9A8522.906619D8 at engcorp.com...
> 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






More information about the Python-list mailing list