9

I would like to use Python to script an application that advertises itself as providing an OLE component. How should I get started?

I don't yet know what methods I need to call on the COMponents I will be accessing. Should I use win32com to load those components, and then start pressing 'tab' in IPython?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
joeforker
  • 40,459
  • 37
  • 151
  • 246

5 Answers5

3

"Python and COM" contains an example. OLE is related to COM and ActiveX so you should look for those terms.

"Python Programming on Win32" is a useful book. There is also a "Python Win32" mailing list.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Brian Lyttle
  • 14,558
  • 15
  • 68
  • 104
2

You need the win32com package. Some examples:

from win32com.client.dynamic import Dispatch

# Excel
excel = Dispatch('Excel.Application')

# Vim
vim = Dispatch('Vim.Application')

And then call whatever you like on them.

Ali Afshar
  • 40,967
  • 12
  • 95
  • 109
2

win32com is a good package to use if you want to use the IDispatch interface to control your objects, but it's slow.

comtypes is a better, native Python, package that uses the raw COM approach to talk to your controls.

WxPython uses comtypes to give you an ActiveX container window from Python.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
ZebZiggle
  • 678
  • 2
  • 9
  • 11
0

Please take a look at the python-win32 package, and, in particular, at its win32com API.

Martin v. Löwis
  • 124,830
  • 17
  • 198
  • 235
0

PythonWin (http://sourceforge.net/projects/pywin32/), bundled with python-win32, comes with its own COM browser as part of its shell and debugging environment.

joeforker
  • 40,459
  • 37
  • 151
  • 246