ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ctypes-users
ctypes-users
Re: [ctypes-users] comtypes 0.2 released
by Thomas Heller other posts by this author
Feb 16 2006 10:13AM messages near this date
RE: [ctypes-users] comtypes 0.2 released | [ctypes-users] ctypes 0.9.9.3 released
Mark McMahon wrote:
>  Hi,
>  
>  I gave a very simple test of comtypes with Passolo (www.passolo.com) and (I think) it didn
't work at all.
>  
>  E.g.
>  
> >>> import comtypes.client
> >>> comtypes.client.Dispatch
>  Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
>  AttributeError: 'module' object has no attribute 'Dispatch'
> >>> comtypes.client.CreateObject("Passolo.UnicodeApplication")
>  Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
>    File "C:\.tools\Python242\Lib\site-packages\comtypes\client\__init__.py", line 514, in C
reateObject
>      obj = comtypes.CoCreateInstance(clsid, clsctx=clsctx, interface=interface)
>    File "C:\.tools\Python242\Lib\site-packages\comtypes\__init__.py", line 809, in CoCreate
Instance
>      _ole32.CoCreateInstance(byref(clsid), punkouter, clsctx, byref(iid), byref(p))
>  WindowsError: [Errno -2147467262] No such interface supported
>  
>  It could be that I have no idea what I am doing (well that's for sure!)
>  

This is how it should work.
Does this object work in pywin32?  Do other COM objects work, for example this:

c:\sf\ctypes_release> py24
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
> >> from comtypes.client import *
> >> ie = CreateObject("InternetExplorer.Application")
# Generating comtypes.gen._EAB22AC0_30C1_11CF_A7EB_0000C05BAE0B_0_1_1
# Generating comtypes.gen.SHDocVw
> >> print ie
<POINTER(IWebBrowser2) object c6c710> 
> >> ie.Visible = True
> >>

>  I then stumbled on
>  comtypes.client.GetModule(r"c:\program files\passolo 5\psl_u.exe")
>  
>  And ended up with a comtypes.gen.PassoloU.
>  
>  But I didn't know how to create a running instance from that, and I didn't really make any
 further progress then that.

In principle the idea was (although it does *not* seem to work in comtypes 0.2)
that CreateObject would also accept coclasses from the generated file as argument.
You have to look into the generated files (or use Pythons help) to figure them out.
For the IE code above, this would have to be spelled:

> >> from comtypes.gen import SHDocVw
> >> help(SHDocVw.WebBrowser)
Help on class WebBrowser in module comtypes.gen._EAB22AC0_30C1_11CF_A7EB_0000C05BAE0B_0_1_1:

class WebBrowser(comtypes.CoClass)
 |  WebBrowser Control
 |
 |  Method resolution order:
 |      WebBrowser
 |      comtypes.CoClass
 |      comtypes._comobject.COMObject
 |      __builtin__.object
 |
[...]
> >> ie = CreateObject(SHDocWv.WebBrowser) # doesn't work correctly (comtypes bug)


>  Not sure if this is a known limitation in comtypes or I am just not using it correctly?


Thomas



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
ctypes-users mailing list
ctypes-users@[...].net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Thread:
Thomas Heller
Mark McMahon
Mark McMahon
Thomas Heller

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved