Here's a few more lines that hook the document's onactivate event. import win32com.client
ie_mod=win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}' ,0, 1, 1) doc_mod=win32com.client.gencache.EnsureModule('{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}' ,0 ,4, 0) class IE_Events(ie_mod.DWebBrowserEvents2): def OnNavigateComplete2(self, pDisp, URL): print 'OnNavigateComplete2:', URL class Doc_Events(doc_mod.HTMLAnchorEvents): def Ononactivate(self): print 'onactivate', self.activeElement.outerHTML ie=win32com.client.DispatchWithEvents('InternetExplorer.Application',IE_Events) ie.Visible=1 ie.Navigate('http://www.google.com') d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events) Roger <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > Thanks for the response and for the code. > However, I want to trap events like mouse click on the HTML document > loaded by the web browser control. The code mentioned below provides > events from the web browser control. I need to find out on which > particular HTML tag did the user click for example. > How do I find that out? There should be some way to refer to a document > from a given web browser control and start receiving events from it > > > Roger Upole wrote: >> The two you'll need to run makepy for are Microsoft Internet Controls > and >> Microsoft HTML object Library. If you run them manually, you should > be >> able to look at the generated code to get the guids. >> Here's a minimal example: >> >> import win32com.client >> >> > ie_mod=win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}',0, > >> 1, 1) >> class IE_Events(ie_mod.DWebBrowserEvents2): >> def OnNavigateComplete2(self, pDisp, URL): >> print 'OnNavigateComplete2:', URL >> >> > ie=win32com.client.DispatchWithEvents('InternetExplorer.Application',IE_Events) >> ie.Visible=1 >> ie.Navigate('http://www.google.com') >> >> hth >> Roger >> >> >> <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> >I am trying to trap events from internet explorer eg. when user > clicks >> > on an html link - I need to get notified for that event. >> > >> > After looking through the newgroups / internet and reading through >> > various sections in programming python on win32 - I understand that >> > this can be done using DispatchWithEvents. >> > I have also referred to discussions on comp.lang.python >> > > http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/a3c502d06412a5f8/0ee3083e71316da7?q=dispatchwithevents&rnum=43#0ee3083e71316da7 >> > >> > and >> > >> > > http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/1da0668794851296/5bcec1fda216c598?q=dispatchwithevents&rnum=19#5bcec1fda216c598 >> > >> > So far - none of the newgroups postings report that IE events were >> > trapped successfully (at least I could not find any). However, > there is >> > enough evidence that it can be done. >> > My problems at the moment: >> > a) The examples use early binding. However, I cannot get Python > makepy >> > to generate the code to force makepy process at run time - since > COM >> > makepy utility that I invoke from python win 32 does not have any > entry >> > for internet explorer. >> > I tried to find the CLSID for IE > 3050F613-98B5-11CF-BB82-00AA00BDCE0B >> > but I get an exception >> > b) Also one of the examples suggest that following code should work >> > >> >> mod = EnsureModule(...) >> > >> >> class MyEvents(mod.IDocumentEvents): >> >> # your methods here.... >> > >> >> handler = MyEvents(ie.document) >> > >> >> # handler should start recieving events. >> > >> > however, what CLSID is to be used in EnsureModule... . I tried with > a >> > few but I always get the error 'NoneType' object has no attribute >> > 'IDocumentEvents' >> > >> > >> > An example that 'works' will be very useful >> > >> >> >> >> ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet > News==---- >> http://www.newsfeeds.com The #1 Newsgroup Service in the World! > 120,000+ Newsgroups >> ----= East and West-Coast Server Farms - Total Privacy via Encryption > =---- > ----== 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