catching msie NewWindow2 event

M

mic

I'm trying to catch the MSIE NewWindow2 event using win32com interface. The
code I use is basically something like below:

from win32com.client import DispatchWithEvents

class Events:
Browser = None
def OnNewWindow2(self, ppDisp, Cancel):
#catching the new window and trying to place it onto my own
ppDisp = Events.Browser
#Cancel = True - this doesn't work either (should prevent popup from
opening)

ie1 = DispatchWithEvents('InternetExplorer.Application', Events)
ie2 = DispatchWithEvents('InternetExplorer.Application', Events)
Events.Browser = ie2
ie1.Navigate('http://jaak.sav.net/test.html') #url to the html document that
opens its own window

I know that setting ppDisp value should work (at least I've seen it working
in C# code) but using it this way gives no results. What's more depending on
the url I use the event is triggered or not (other standard events work
okay). I've seen ctypes COM implementation demo that makes similiar things
but it looks so much more complicated than win32com api. Hope somebody has
some insight on that...

Regards,

Michal
 
R

Roger Upole

You have to return the out parameters.
Try adding
return ppDisp,True
to the bottom of OnNewWindow2.

Roger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top