[python-win32] win32com and DispatchWithEvents()
Ryan Neve
ryan.neve at gmail.com
Fri Nov 14 14:46:28 CET 2008
I posted this on comp.lang.python. but it has been pointed out to me that
this is a better place to ask.
I'm trying to get DispatchWithEvents() to work with HyperAccess (terminal
program) without much success.
This works but doesn't handle the "Event Driven Functions":
haObj = win32com.client.Dispatch(r"HAWin32")
I'm certainly new to all this but I've done a bunch of searching on google
and found some examples using IE. This is derived from eventsFreeThreaded.py
and eventsApartmentThreaded.py included as demos with win32com. I have to
admit I don't really get the difference between Free Threaded and Apartment
threaded or which I should be using. I feel like I'm in over my ability
level, but that's usually how you learn.
This Internet Explorer Example works:
ieObj = win32com.client.DispatchWithEvents("InternetExplorer.Application",
ExplorerEvents)
But this does not:
haObj = win32com.client.DispatchWithEvents("HAWin32", HAEvents)
It fails with the error message:
"TypeError: This COM object can not automate the makepy process - please run
makepy manually for this object"
I looked in the files generated by makepy (I used the COM Makepy utility in
PythonWin) and after some searching I tried:
mod =
win32com.client.gencache.EnsureModule('{5178CCE1-AAEF-11CE-AE75-00AA0030EBC8}',
0, 1, 0)
haObj = win32com.client.DispatchWithEvents(mod, HAEvents)
Which fails with the error message:
ttributeError: 'module' object has no attribute 'GetTypeInfo'
So I tried this approach with IE:
mod =
win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B8}',
0, 1, 0)
ieObj = win32com.client.DispatchWithEvents(mod, ExplorerEvents)
But this too breaks with the same GetTypeInfo error.
Any ideas or resources? I can provide the makepy output if that helps.
Here's a thread that almost mirrors my experience but never seems to come to
a conclusion:
http://mail.python.org/pipermail/python-win32/2006-August/004888.html
Regards,
-Ryan Neve
UNC CH Inst. of Marine Sciences
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20081114/517ac1ac/attachment.htm>
More information about the python-win32
mailing list