<p><font face="courier new,monospace"># Hi<br># I want to get events of FrontPage Web and Page object models with this code.<br># OnPageNew and OnActivate works properly but when I click on the page nothing happen.<br># I know that I want to get events of two different COM objects.
<br># But I don't know how can I do that.<br># (I run this when FrontPage is active. Then I create a new page.)<br># Thanks</font></p>
<p><font face="courier new,monospace">from win32com.client import DispatchWithEvents<br>import time, pythoncom, msvcrt, types</font></p>
<p><font face="courier new,monospace">class FrontPageEvents:<br> def __init__(self):<br> print 'FrontPageEvents'<br> def OnPageNew(self, page):<br> global t1, t2<br> t1=DispatchWithEvents(page, PageExEvents)
<br> t2=DispatchWithEvents(fp.ActiveDocument, PageEvents)<br> print fp.ActiveDocument</font></p>
<p><font face="courier new,monospace">class PageExEvents:<br> def __init__(self):<br> print 'PageExEvents'<br> def OnActivate(self):<br> print 'OnActivate'</font></p>
<p><font face="courier new,monospace">class PageEvents:<br> def __init__(self):<br> print 'PageEvents'<br> def onclick(self):<br> print 'onclick'</font></p>
<p><font face="courier new,monospace">t1=None<br>t2=None<br>fp=DispatchWithEvents("FrontPage.Application", FrontPageEvents)</font></p>
<p><font face="courier new,monospace">while not msvcrt.kbhit():<br> pythoncom.PumpWaitingMessages()<br> time.sleep(.2)<br>msvcrt.getch()<br></font></p>