473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

COM automation, Internet Explorer, DocumentComplete event

I'm very new to Python and have a question concerning IE automation and
detection of page completion.

The MSDN article 180366 states in part:

----
The top-level frame fires the DocumentComplete in the end. So, to check
if a page is done downloading, you need to check if the IDispatch*
parameter is same as the IDispatch of the WebBrowser control.

For Visual Basic, here is code that performs this check:

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object,
URL As Variant)
If (pDisp Is WebBrowser1.Object) Then
Debug.Print "Web document is finished downloading"
End If
End Sub
----

I'm able to catch IE's events including DocumentComplete with:

def OnDocumentComplete(self, pDisp, URL):

so i have pDisp. Self is the object returned by:

self.ie = DispatchWithEvents("InternetExplorer.Application",
InternetExplorerEvents)

that created the automation object. How do I perform the test in
Python?

Thanks for any help.

Jan 10 '06 #1
5 4563
puff wrote:
I'm able to catch IE's events including DocumentComplete with:

def OnDocumentComplete(self, pDisp, URL):

so i have pDisp. Self is the object returned by:

self.ie = DispatchWithEvents("InternetExplorer.Application",
InternetExplorerEvents)

that created the automation object. How do I perform the test in
Python?


This recipe might give you some clues; you can use the Busy attribute,
instead of a DocumentComplete handler:

http://herlock.com/ob/pythoncb/05960...0-sect-15.html

Graham

Jan 10 '06 #2
Without going into an overly long discussion, suffice to say that the
busy attribute, notwithstanding Microsoft documentation to the
contrary, simply doesn't work.

BTW, there are a fair number of URLs for which PAMIE's combination of
busy and readystate doesn't work.

This scheme is somewhat better than both, but (of course it could only
be) also doesn't work under some cases. Nevertheless, it's better
than depending on busy or ready state.

So how do I do the equivalent of pDisp Is WebBrowser1.Object in python?

Jan 10 '06 #3
PythonCom interfaces implement __cmp__ so that you can just use
a straight == comparison.

hth
Roger

"puff" <rb********@earthlink.net> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...
I'm very new to Python and have a question concerning IE automation and
detection of page completion.

The MSDN article 180366 states in part:

----
The top-level frame fires the DocumentComplete in the end. So, to check
if a page is done downloading, you need to check if the IDispatch*
parameter is same as the IDispatch of the WebBrowser control.

For Visual Basic, here is code that performs this check:

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object,
URL As Variant)
If (pDisp Is WebBrowser1.Object) Then
Debug.Print "Web document is finished downloading"
End If
End Sub
----

I'm able to catch IE's events including DocumentComplete with:

def OnDocumentComplete(self, pDisp, URL):

so i have pDisp. Self is the object returned by:

self.ie = DispatchWithEvents("InternetExplorer.Application",
InternetExplorerEvents)

that created the automation object. How do I perform the test in
Python?

Thanks for any help.



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jan 10 '06 #4
Thanks very much Roger.

As you might have guessed, I'm rather new to Python. The notion that
== does the job illustrates one of the reason's I've undertaken
learning yet another new language (40+ years on, the language count is
rather larger than I'd care to admit). I should also mention the
fact that a newsgroup post actually gets an answer is a big plus.
Thanks again.

I was in a bit of a rush in my post about busy. Let me take a minute
to explain on the off chance that someone else might benefit.

IE's busy attribute doesn't work for determining when a page has
fully downloaded. It only indicates IE's internal work state. If you
watch the event stream, busy, and readystate while pages are loading
you often see busy go false and then go true again fairly quickly. So,
busy as a reliable check for page completely loaded is a fairly poor
choice.

I mentioned PAMIE. It uses a technique that waits for busy false, then
readystate complete. This is much better than simple busy, but suffers
from two flaws. First the last time I looked at that PAMIE's code
the checks were serial. So it can get confused by an early busy false,
then go into it's readystate complete check inappropriately early.
This aside, there are pages where during loading, busy is false and
ready state complete for a short time then more page content is
downloaded (watching the event stream from real world pages is a very
informative experience when it comes to a page being complete).

The technique suggested in the MS KB article, actually works fairly
well for determining when the page is in fact fully downloaded as a
result of the thing that started the navigation (lots of things other
than navigate can cause navigations, BTW). It basically means that the
browser has all the bytes associated with the page in hand.
Unfortunately, it also fails (although rather less often than any
technique involving either busy or readystate) when the page has script
that mucks about with the DOM, causes additional activity over the web,
etc.

Thanks again.

Jan 10 '06 #5
R. Bell,

If you could sent me those URLS that are not working with PAMIE it
would be great.
It should be a quick fix. I haven't had any of the Users report this as
of yet.

I notice your writing an app that automates IE also, best of luck with
it!!
Rob

Jan 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mic | last post by:
I'm currently trying to write an MSIE automation software and have run into such problem - have no idea how to take control of external popup windows - I use WebBrowser COM object and am able to...
0
by: calfdog | last post by:
PAMIE 1.50 released!! Now with Frames suport Why wait, when you could be using this to Automate now!... It's Free!!! http://pamie.sourceforge.net ...
3
by: Robert | last post by:
---EN--- This message has been crossposted in a french speaking newsgroup, english version is at the end. Thanks a lot for your help... --/EN--- Bonjour, Je développe une application...
2
by: Daniel B. Harwood | last post by:
Using C# Standard Edition 2003 (a bargain!), I have written a multi-threaded Windows forms application which checks Web sites of interest for newly posted Web pages. On detecting a new page it...
2
by: RJB | last post by:
I'm working on a VB application that must run 24x7 for a LONG time, think 60 days of so. As part of what it does it must automate an instance of IE and navigate to many different URLs, think many...
3
by: Richard Bell | last post by:
I'm working on a VB application that must run 24x7 for a LONG time, think 60 days of so. As part of what it does it must automate an instance of IE and navigate to many different URLs, think many...
16
by: VBSome | last post by:
As far as I understand there is no native VB.NET equivalent of the VB6 Web browser control. There are some things I can play with HTML wise, but none do what I really need to do (which is...
1
by: Apu Nahasapeemapetilon | last post by:
Hello and thank you in advance for your help. Can anyone think of a reason why this code would work properly on one PC, but not another? I've got a System.Windows.Forms.UserControl that...
2
by: medak | last post by:
Hi, I am trying to automate internet explorer using Active Perl’s Win32::OLE Module I know that WithEvents(OBJECT]method enables and disables the firing of events by the specified OBJECT. And...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.