[python-win32] How to get IWebBrowser2 from a HWND
salvatore ventura
venturasalvatore at yahoo.it
Sun Jul 13 02:00:10 CEST 2008
Hi,
to make things easier, I have attached two htm files that display
my scenario:
- main.htm has a link, that once clicked will open a modal popup
dialog.htm) that has an input text box.
What I would like to achieve is the IWebBrowser2 object of the
dialog.htm page. I know I can access anything on the page itself
via the IHTMLDocument2 (which I already have) but that's not my
need.
For testing, to make things easy, for now, I open the web page
and click on the link from *outside* of the python script, then
have the script go ahead and figure the windows names etc etc...
In the real scenario, one python script will drive the dialog
opening, but I will use a second thread to deal with the dialog.
I am using PAMIE, and the thread idea is freely mutuated from
the cModalPopUp class that comes with it (which only deals with
alert boxes and similar though).
I have also attached a zip file with the whole ball (python test
script, htm files, the winAutoGui.py that you may know already,
and the tlb file for the service provider, which I found on the
web.
Thanks again for the help, I will be experimenting other ways
around this in the meanwhile.
regards,
.salvo
--- Sab 12/7/08, salvatore ventura <venturasalvatore at yahoo.it> ha scritto:
> Da: salvatore ventura <venturasalvatore at yahoo.it>
> Oggetto: RE: [python-win32] How to get IWebBrowser2 from a HWND
> A: python-win32 at python.org
> Data: Sabato 12 luglio 2008, 15:47
> Hi Mark, Tim,
> thanks for the prompt responses.
>
> Tim,
> the code you suggest does not help me in this context, as
> it is not able to 'see' the HWND of the modal popup
> as an IE (ShellWindow) one. In fact, that code is only able
> to get the main IE app window.
>
> Mark,
> I tried what you suggest, two ways (following my previous
> code):
>
> pIServiceProvider.QueryService(IWebBrowserApp._iid_,
> GUID(pythoncom.IID_IDispatch))
>
> win32com.client.Dispatch(pIServiceProvider.QueryService(IWebBrowserApp._iid_,
> GUID(pythoncom.IID_IDispatch)))
>
> Still I get the 'No such interface supported'.
>
> Now, I start to think that somehow I am not (in the class
> structure) in the place I think I am, but I am not too sure
> of how to know that. Will the 'type' on an object be
> reliable in these cases? Or will it just reflect what the
> variable has been defined as (which would be my guess)?
>
> In other words, how will I be able to debug this?
>
> I am somehow new to both python and COM, so sorry if some
> questions will be silly...
>
>
> thanks a lot!
> .salvo
>
>
>
> --- Gio 10/7/08, Mark Hammond
> <mhammond at skippinet.com.au> ha scritto:
>
> > Da: Mark Hammond <mhammond at skippinet.com.au>
> > Oggetto: RE: [python-win32] How to get IWebBrowser2
> from a HWND
> > A: "'salvatore ventura'"
> <venturasalvatore at yahoo.it>, python-win32 at python.org
> > Data: Giovedì 10 luglio 2008, 23:53
> > > # ... and the IWebBrowser2:
> > > ie =
> > pIServiceProvider.QueryService(IWebBrowserApp._iid_,
> > > IWebBrowser2._iid_)
> > >
> > > # which - of course - fails.
> > >
> > >
> > > Error returned:
> > > Traceback (most recent call last):
> > > File "<interactive input>",
> line 1,
> > in <module>
> > > COMError: (-2147467262, 'No such interface
> > supported', (None, None,
> > > None, 0, None))
> >
> > Its possible that you could specify IDispatch as the
> second
> > IID, then wrap
> > the resulting object using win32com.client.Dispatch()
> (or
> > the equivalent
> > using ctypes).
> >
> > Cheers,
> >
> > Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080713/382d376e/attachment-0002.htm>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080713/382d376e/attachment-0003.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IE_modals.zip
Type: application/x-zip-compressed
Size: 11161 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080713/382d376e/attachment-0001.bin>
More information about the python-win32
mailing list