Using COM object in Python


COM technolgy is very mature and common. It is almost everywhere in Windows platform. In order to access COM objects in Python, you probably require to install ‘Win32 extension for Python‘.

It seems that for each version of python, you need to install each separate extensions.

Below is the short example of using COM object in python script, after ‘Win32 extension‘ has been installed.

from win32com import client

obj = client.Dispatch("WScript.Shell")

def hello(x):
    obj.popup("Hello " + x + "!")

hello("World")

The client object is in the package win32com. The required method to create object, i.e. similarly to new ActiveXObject in javascript, is Dispatch.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
195 words
Last Post: First Experience in Online Contest
Next Post: Codeforces: A. Vasya and the Bus

The Permanent URL is: Using COM object in Python

Leave a Reply