List of all methods in COMobject
Is it possible?
Something along the lines:
import win32com.client
ProgID = "someProgramID"
com_object = win32com.client.Dispatch(ProgID)
for methods in com_object:
print methods
I got com_object.__dict__
one that lists:
[_oleobj_, _lazydata_, _olerepr_, _unicode_to_string_, _enum_, _username_, _mapCachedItems_, _builtMethods_]
Most of them are empty except:
-
_oleobj_
(PyIDispatch) -
_lazydata_
(PyITypeInfo) -
_olerepr_
(LazyDispatchItem instance) -
_username_
(<unknown>
)
But I don't know how to access anything in these types.
+3
source to share
2 answers
Just found how to get most of the methods:
Here's how:
import win32com.client
import pythoncom
ProgID = "someProgramID"
com_object = win32com.client.Dispatch(ProgID)
for key in dir(com_object):
method = getattr(com_object,key)
if str(type(method)) == "<type 'instance'>":
print key
for sub_method in dir(method):
if not sub_method.startswith("_") and not "clsid" in sub_method.lower():
print "\t"+sub_method
else:
print "\t",method
Here's an example output with ProgID = "Foobar2000.Application.0.7"
Output:
Playlists
Add
GetSortedTracks
GetTracks
Item
Load
Move
Remove
Save
Name
foobar2000 v1.1.13
ApplicationPath
C:\Program Files (x86)\foobar2000\foobar2000.exe
MediaLibrary
GetSortedTracks
GetTracks
Rescan
Minimized
True
Playback
FormatTitle
FormatTitleEx
Next
Pause
Previous
Random
Seek
SeekRelative
Start
Stop
ProfilePath
file://C:\Users\user\AppData\Roaming\foobar2000
+1
source to share