Let's say I use
app = win32com.client.dynamic.Dispatch("InDesign.Application")
to obtain an InDesign Application object. Now I can use
mainmenu = app.menus["$ID/Main"]
to access InDesign's main menu, but unfortunately end up with only <COM object <unknown>>
for everything. If I use
app = win32com.client.gencache.EnsureDispatch("InDesign.Application")
instead, I get a more meaningful <win32com.gen_py.Adobe InDesign CC 2015 TypeLibrary._Application instance at 0x....>
and dir(app)
lists some properties (excluding menus
) but now I need to use both uppercase app.Menus
and cannot use Pythonic item indexing but have to resort to the awful
mainmenu = app.Menus.Items("$ID/Main")
instead. Is there any way to get the best of both worlds?
edit I have the respective .tlb
-file, does that help somehow? Or would I really have to write a wrapper (or delegator?) for each COM object I'd like to use? Isn't that the same what win32com.client.makepy
seems to do?