win32: anybody used IE's OnNewWindow2 event??

gcash gcash at luncheonmeat.cfl.rr.com
Tue Jul 29 21:58:07 EDT 2003


OK, I've written a tool to do a bunch of Internet Explorer point&click
using win32all, and it's been rather fun.

I've run into a sticking point though... when I click some links, they
open up a new window where they expect you to fill out a form, and
when you submit it, it closes the window and forces the main screen to
a new URL.

Problem is, I can't find *ANY* way of getting control of that window,
in order to fill out the form automatically.  There's no data
structure that seems to lead to other windows associated with a
session.

Some of the small windows I've simply dissected the code and used
httplib to submit the form, then forced the URL navigation
myself. However, some of the windows are rather nasty pieces of
javascript that aren't amenable to this approach.

There's supposed to be an event called "OnNewWindow2" called when a
page opens a new window through javascript or a "target" parameter.

It has 2 parameters: an object and a cancel flag.  These seem to be
"out" parameters, and I think you're supposed to whip up a new
InternetExplorer.Application.1 and pass it back in the object
parameter or set the cancel parameter to false.  The new app object is
then used for the new window.

This event *does* get fired when it should, but both the arguments are
"None".

I can't figure out how to use this... can somebody help me out?  I
tried googling about this and got almost no hits.

Does anyone have example code?

I've also looked at the genpy-generated code, looking for some sort of
handle on finding "child" subwindows (not frames, new top-level
instances) Is there some trick I'm missing??  Given a link "target"
name, can I find the instance of explorer (i.e. the "document" object)
that's servicing that window?

This is kicking my butt.

-gc

-- 
I've never tried emacs because I already _have_ an OS on this peecee.
-- mikea at mikea.ath.cx (Mike Andrews)




More information about the Python-list mailing list