Python ActiveX automation

python com object
python office automation
python windows automation
python component object model
python com interface
python win32com.client.dispatch documentation
python word automation

I am trying to use ActiveX automation with python to control Audio Precision ATS-2. I am using pywin32 32-bit Windows XP with Python 2.7.

I installed the audio Precision software. Then I used makepy utility which found Audio Precision in the list and created a wrapper for it. Everything is going well until I attempt to call dispatch function abd I am stuck.

from guides I found online,

win32com.client.Dispatch("Excel.Application")

What should I put in the area that says "Excel.Application"?

How can I find this?

When I used OLE/COM Object viewer, I see Audio Precision entries under type library, but I am unsure how does the information in it could help me.

I have attempted few things on my own, but got almost no result. The best result I got was when I entered the CLSID in dispatch function, which I found in the wrapper object makepy created.

win32com.client.Dispatch("{80EC6E76-D94F-48EB-8F4C-05BDD7850BF1}")

which gave me the following error:

    Traceback (most recent call last):
  File "C:\Python27\Lib\site-packages\win32com\gen_py\APtest.py", line 5, in <module>
    xlApp = win32com.client.Dispatch("{80EC6E76-D94F-48EB-8F4C-05BDD7850BF1}")
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 85, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
com_error: (-2147221164, 'Class not registered', None, None)

I have:

  • looked under the registry, and the ID is indeed not registered anywhere. There are few Audio Precision entries, but doesn't look like it has anything that could fix this.
  • attempted reinstalling the Audio Precision software, but it didn't help.
  • attempted to register the dll objects in the Audio Precision control(ATS 1.60) software with regsrv32, but all gave errors and would not register(which I suspect aren't the right ones I need to register)

How can I fix this?

Automating Windows Applications Using COM, using python and Microsoft's COM technology to automate Windows (​compound documents) and ActiveX (Internet-enabled components)  This library aimed to simplify writing ActiveX Automation scripts for AutoCAD with Python. See more examples in source distribution. Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

To use the pywin32 module with an activex class you need to generate a wrapper file. To do this locate your makepy.py file in C:\Python27\Lib\site-packages\win32com\client (or your simmilar dir). Then run it, locate the NAME of your activex class then run it. It should generate a wrapper file in the gen_py folder C:\Python27\Lib\site-packages\win32com\gen_py with the CLSID in it. You can then access it like the excel example and the same way you would in other languages.

ActiveX - Python Introduction, An ActiveX control is an OLE control that can live inside an HTML page it can be (COM) applications improving performance automation objects bindings early. I am trying to use ActiveX automation with python to control Audio Precision ATS-2. I am using pywin32 32-bit Windows XP with Python 2.7. I installed the audio Precision software. Then I used mak

I had the same issue. I didn't know where to get that, which from what I can gather is the name of the CoClass (which I believe is the wrapper for the dll) created by the makepy program (maybe I'm wrong). After I read the answer by @NotAUser I found it, but when I inspected the file created by the makepy program, and right before the last class, (if more than one are created) I found the following:

from win32com.client import CoClassBaseClass
# This CoClass is known by the name 'ZKFPEngXControl.ZKFPEngX'
class ZKFPEngX(CoClassBaseClass): # A CoClass

So, there, in the same file there was the name I needed to use.

Implementing COM Objects in Python, win32com.axscript— This is the ActiveX Scripting implementation for automation-capable language, such as Python, Visual Basic, Delphi,  I am trying to use ActiveX automation with python to control Audio Precision ATS-2. I am using pywin32 32-bit Windows XP with Python 2.7. I installed the audio Precision software. Then I used makepy utility which found Audio Precision in the list and created a wrapper for it. Everything is going well until I attempt to call dispatch function

Solved: python and activeX - NI Community, Solved: We want to do some test automation, using Python and LabVIEW. For example, we want to set rig speed to be 1000 rpm. first, we set  Fortunately, python has the “Python for Windows Extensions” package known as pywin32 that allows us to easily access Window’s Component Object Model (COM) and control Microsoft applications via python. This article will cover some basic use cases for this type of automation and how to get up and running with some useful scripts.

com Python ActiveX automation?, To do this locate your makepy.py file in C:\Python27\Lib\site-packages\win32com​\client (or your simmilar dir). Then run it, locate the NAME of your activex class  On the Windows platform, Python has an excellent interface to COM (also known as ActiveX) and can be used to interface to almost any COM program (such as the MS-Office suite). Again, Python scripting can be added to enhance a project without change to the existing COM components. (See Win32All)

Playing with ActiveX, Python and Variant., Recently I had to write a script to automate a several operation in a several aimed to simplify writing ActiveX Automation scripts for AutoCAD with Python",  Once you've mastered the basics of programming, you'll create Python programs that effortlessly perform useful and impressive feats of automation to: Search for text in a file or across multiple files Create, update, move, and rename files and folders Search the Web and download online content

Comments
  • Thanks for this step! Just know this.