> This might make a good candidate for the Cookbook (or there's > a collection of IE automation examples at win32com.de) > so anybody else trying to do something similar knows some of the pitfalls.
This thread has been very valuable for me and has provided clarifications which I could not get after hours of surfing web /reading python on win32 / python developer handbook and so on. Here are more questions that I am encountering a) the code above will return a click event from an anchor element. However, I need to identify which anchor element was clicked on. Similarly, if a user clicks on one cell in HTML table - I need to determine its identity. One possible solution to this will be to look at the onClick event provided by HTML_DocumentEvents and as desribed in msdn library http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/events/events.asp The problem is that msdn documentation says that in order to identify the element that was clicked - one has to query on IHTMLWindow2::event property on iHTMLWindow2 interface to get IEventOBj interface and then from there - use query interfce to get to the id of the element. How do I do this in python? ie. I have this code class Doc_Events(doc_mod.HTMLDocumentEvents): def Ononclick(self): print 'onClick fired ' and I see onClick being trapped. Now I need to go and get a reference to the iHTMLWindow2 interface. For this I need to get a reference to doc_mod (as far as I can see). How do I get that in the OnonClick method above. b) You had mentioned PumpWaitingMessages in the previous posting. I first encountered this on newsgroup postings. None of the standard books (python on win32 / python developer) seem to explain this in detail although this seems to be commonly used. Though I understand this now - my problem is that there seems to be a lack of cohesive explanation on how python ties up with COM (despite a good chapter 12 on python win32 book). How does a newbie get more info on coding? Essentially (a) is also a generic question which can be included in a standard text. If nothing of this sort exists - maybe I will think of jotting down the notes and posting on a public website. Roger Upole wrote: > Reducing the sleep time in the loop also seems to speed things up. > I'm guessing due to giving both event loops more resources, but > I can't prove it conclusively. > > This might make a good candidate for the Cookbook (or there's > a collection of IE automation examples at win32com.de) > so anybody else trying to do something similar knows some of the pitfalls. > > Roger > > "J Correia" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > "Roger Upole" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> There does appear to be some sort of conflict between the two event > >> hooks. I wasn't seeing it before since IE was getting google from my > >> browser cache and it was coming up almost instantaneously. As soon > >> as I switched the URL to a page that loads slowly, I got the same > >> result. > >> > >> Adding win32gui.PumpWaitingMessages() to the wait loop > >> seems to allow both event hooks to run without blocking each other. > >> > >> Roger > > > > I added that line to the wait loop and while it does indeed speed it > > up dramatically (in 10 tests: min = 13 sec; max = 33, ave ~ 20 secs) > > it's still nowhere near the 1-2 secs it takes without hooking the > > IE events. I also can't explain the wide differences between min > > and max times since they seem to occur randomly > > (e.g. min occurred on 7th run, max on 4th). > > > > I assume that that response time won't be adequate for the original > > poster's needs, due to the slowdown in browsing for his users. > > > > Jose > > > > > > > > > > > > > > > ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-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 =--- -- http://mail.python.org/mailman/listinfo/python-list