FAQ
I'm having problems with some attributes in Internet Explorer.

I'm trying to figure out how to set things up so I don't have to do my
own event loop even though I'm using DispatchWithEvents()

The reason why is that I'm doing lots of "looking at the IE Document
object then poking IE" processing. Specifically I'm trying to
implement an IE "object" that you can use to write "macro" scripts to
do long and boring point'n'click routines in Oracle Portal.

One of the reasons I need to use DispatchWithEvents() is to grab the
OnNewWindow2 event and get a reference to any new windows that get
opened either by javascript or targeted links. Otherwise I'd not use
events, which releases you from needing to pump events.

I've read "Python Programming on Win32" (and tried really hard to grok
Appendix D) and googled until they threatened to block my IP address.

example #1
import time
import pythoncom as pc
import win32com.client as wc

class EventsClass:
pass

ie=wc.DispatchWithEvents('InternetExplorer.Application.1', EventsClass)
ie.Visible=1
ie.Navigate('http://www.webexpressions.com/how-to/examples/frames/frame4.htm')
while ie.ReadyState != 4:
time.sleep(0.25)
pc.PumpWaitingMessages()
print ie.Document.frames
print ie.Document.frames.length
for i in range(ie.Document.frames.length):
print ie.Document.frames[i].name
print ie.Document.parentWindow

while 1:
time.sleep(0.25)
pc.PumpWaitingMessages()

OK, you run this and it prints:
[object]
3
menu
header
main
[object]

This is ok except for the event loop. So experimented with
sys.coinit_flags, which does get rid of the need to pump events, but
then the "parentWindow" and "frames" attributes no longer work!!!

(the "frames" collection is the IE instances (I think) for each of the
frame subwindows, each with their own Document objects, etc)

example #2
import sys
sys.coinit_flags = 0

import time
import win32com.client as wc

class EventsClass:
pass

ie=wc.DispatchWithEvents('InternetExplorer.Application.1', EventsClass)
ie.Visible=1
ie.Navigate('http://www.webexpressions.com/how-to/examples/frames/frame4.htm')
while ie.ReadyState != 4:
time.sleep(0.25)
print ie.Document.frames
print ie.Document.frames.length
for i in range(ie.Document.frames.length):
print ie.Document.frames[i].name
print ie.Document.parentWindow

Traceback (most recent call last):
File "C:\example2.py", line 15, in ?
print ie.Document.frames
File "C:\PROGRA~1\PYTHON\lib\site-packages\win32com\client\dynamic.py", line 4
54, in __getattr__
raise pythoncom.com_error, details
pywintypes.com_error: (-2147467262, 'No such interface supported', None, None)
>>>

Why is this? What's going on here?

-gc

--
Windows users [are like] people stuck in abusive relationships. They
get beat up over and over again, but they won't leave.
-- Steve VanDevender (alt.sysadmin.recovery)

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedAug 31, '03 at 12:57a
activeAug 31, '03 at 12:57a
posts1
users1
websitepython.org

1 user in discussion

Gcash: 1 post

People

Translate

site design / logo © 2022 Grokbase