RE: Get all attributes of a com object
[Stefan Schukat] | You can only build a proxy module if you have the typelibrary | information which not all programs provide, since it prohibits | changes in the interface the easy way. E.g., MFC application | will normally not provide a typelibrary but support dynamic | dispatch. Oh. Thanks. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
Many thanks to all of you; I learned a lot and will come up next time hopefully with some less utopic project ... :-) Wolfgang -- http://mail.python.org/mailman/listinfo/python-list
RE: Get all attributes of a com object
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Tim Golden > Sent: Friday, April 28, 2006 11:45 AM > To: python-list@python.org > Subject: RE: Get all attributes of a com object > > [snip] > > The only thing is that you can't always build a proxy module. > I'm never quite sure why or why not. > You can only build a proxy module if you have the typelibrary information which not all programs provide, since it prohibits changes in the interface the easy way. E.g., MFC application will normally not provide a typelibrary but support dynamic dispatch. Stefan -- http://mail.python.org/mailman/listinfo/python-list
RE: Get all attributes of a com object
[bruno at modulix] | Duncan Booth wrote: | > That will show him the attributes of the Python wrapper | around the COM | > object, it won't show him the attributes of the underlying | COM object | > itself. | | I stand corrected - and shouldn't answer questions about MS technos :( In fact, if a static wrapper has been built for the object in question, the usual help (), inspect () stuff will work, eg: import win32com.client # # Make sure a proxy module is built behind-the-scenes # word = win32com.client.gencache.EnsureDispatch ("Word.Application") help (word.__class__) class _Application(win32com.client.DispatchBaseClass) | Methods defined here: | | Activate(self) | | AddAddress(self, TagID=, Value=) | | AutomaticChange(self) | | BuildKeyCode(self, Arg1=, Arg2=, Arg3=, Arg4=) | | CentimetersToPoints(self, Centimeters=) | | ChangeFileOpenDirectory(self, Path=) | | CheckGrammar(self, String=) [snip] The only thing is that you can't always build a proxy module. I'm never quite sure why or why not. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
Duncan Booth wrote: > bruno at modulix wrote: > > >>eicwo01 wrote: >> >>>Thanks for your tips. >>>But dir() and inspect did not really help. >> >>Really ? >> >>def dump(obj): >> for name in dir(obj): >> print getattr(obj, name) >> > > > That will show him the attributes of the Python wrapper around the COM > object, it won't show him the attributes of the underlying COM object > itself. I stand corrected - and shouldn't answer questions about MS technos :( (snip) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
RE: Get all attributes of a com object
Hello, you only get information about a COM object when you have a wrapper. But you are using the dynamic invoke (Dispatch). So try the typelibrary browser in Pythonwin or use the generated wrapper with makepy or gencache.EnsureDispatch. But dir will give you only the methods and internal classes. The properties you get with OBJ._prop_map_get_.keys(). Stefan > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of bruno at modulix > Sent: Friday, April 28, 2006 10:29 AM > To: python-list@python.org > Subject: Re: Get all attributes of a com object > > eicwo01 wrote: > > Thanks for your tips. > > But dir() and inspect did not really help. > > Really ? > > def dump(obj): > for name in dir(obj): > print getattr(obj, name) > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in > p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
bruno at modulix wrote: > eicwo01 wrote: >> Thanks for your tips. >> But dir() and inspect did not really help. > > Really ? > > def dump(obj): > for name in dir(obj): > print getattr(obj, name) > That will show him the attributes of the Python wrapper around the COM object, it won't show him the attributes of the underlying COM object itself. If I remember correctly (and its a while since I did this), you may be able to use win32com/client/makepy.py to generate a .py file from a type library. If you do this then the python wrapper will have methods to forward the calls, so you can inspect it as above. Unfortunately, not all COM objects have to have type libraries, so it isn't always possible to do this and then you have to fall back on reading the documentation for whatever COM object you are using. You can also embed a call to gencache.EnsureModule() into your code to generate the needed wrappers automatically: the output from makepy tells you this. The easy way to run makepy is to run PythonWin and use 'COM makepy utility' from its tool menu. Then all you have to do is figure out which of the type libraries in the system is the relevant one. -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
eicwo01 wrote: > Thanks for your tips. > But dir() and inspect did not really help. Really ? def dump(obj): for name in dir(obj): print getattr(obj, name) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
Thanks for your tips. But dir() and inspect did not really help. dir(): ['GetIDsOfNames', 'GetTypeInfo', 'GetTypeInfoCount', 'Invoke', 'InvokeTypes', 'QueryInterface', '_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum', '_Release_', '__AttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__', '__getattr__', '__getitem__', '__init__', '__int__', '__len__', '__module__', '__nonzero__', '__repr__', '__setattr__', '__setitem__', '__str__', '_builtMethods_', '_enum_', '_find_dispatch_type_', '_get_good_object_', '_get_good_single_object_', '_lazydata_', '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_', '_print_details_', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_'] pprint.pprint(inspect.getmembers(objDom)): [('GetIDsOfNames', ), ('GetTypeInfo', ), ('GetTypeInfoCount', ), ('Invoke', ), ('InvokeTypes', ), ('QueryInterface', >>), ('_ApplyTypes_', >>), ... Further more this nice method also did not know any more: objDom._print_details_(): AxDispatch container Dispatch wrapper around Methods: Props: Get Props: Put Props: Any additional hint ? Could it be, that you must know in advance, what to ask a com object; so there is no dump possibility ? Thanks Wolfgang -- http://mail.python.org/mailman/listinfo/python-list
Re: Get all attributes of a com object
eicwo01 wrote: > Without to know the names, is it possible to dump all attributes of a > com object? > from win32com.adsi import * from module import * is Bad(tm) > objDom = ADsOpenObject("LDAP:/ ... > print ???"all attributes"??? of objDom Look at dir() and the inspect module. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Get all attributes of a com object
Without to know the names, is it possible to dump all attributes of a com object? from win32com.adsi import * objDom = ADsOpenObject("LDAP:/ ... print ???"all attributes"??? of objDom Thanks Wolfgang -- http://mail.python.org/mailman/listinfo/python-list