Skip to content

Windows: COM Automation

Automation Mechanism

COM (Component Object Model) is Windows's binary interface standard, supported by almost all Windows applications and the Office suite.

IPC Method: COM IPC

  • COM uses the IDispatch interface for cross-process calls
  • This is Windows's native IPC mechanism with excellent performance

Examples

PowerShell

powershell
$outlook = New-Object -ComObject Outlook.Application
$mail = $outlook.CreateItem(0)
$mail.To = "alice@example.com"
$mail.Subject = "Hello"
$mail.Body = "Hi Alice..."
$mail.Send()

Python (pywin32)

python
import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application")
mail = outlook.CreateItem(0)
mail.To = "alice@example.com"
mail.Subject = "Hello"
mail.Body = "Hi Alice..."
mail.Send()

Integration Guide

Existing automation support

If the application already supports COM, zero code is needed to integrate with AAI:

  1. Confirm the application's ProgID (e.g., MyApp.Application)
  2. Write aai.json configuration file
  3. Place in %USERPROFILE%\.aai\<appId>\aai.json
  4. Done!

No automation support

If the application has no automation support, you need to:

  1. Implement COM IDispatch interface (C#/C++)
  2. Register ProgID
  3. Write aai.json configuration file

aai.json Fields

FieldTypeDescription
platforms.windows.automationstringAutomation type: com
platforms.windows.progidstringCOM ProgID (e.g., Outlook.Application)
platforms.windows.tools[].scriptarrayCOM operation sequence
platforms.windows.tools[].script[].actionstringOperation type: create (create object), call (call method), set (set property), get (get property), return (return result)
platforms.windows.tools[].script[].varstringVariable name (for storing return values)
platforms.windows.tools[].script[].objectstringObject reference (e.g., mail, app)
platforms.windows.tools[].script[].progidstringProgID (only used in create operations)
platforms.windows.tools[].script[].methodstringMethod name (only used in call operations)
platforms.windows.tools[].script[].propertystringProperty name (only used in set/get operations)
platforms.windows.tools[].script[].valuestringProperty value (supports ${param} placeholders)
platforms.windows.tools[].script[].argsarrayMethod arguments (supports ${param} placeholders)
platforms.windows.tools[].output_parserstringOutput parsing method: last_result (return value of last operation)
platforms.windows.tools[].timeoutintegerTimeout in seconds, default 30

Back to Spec Index | Back to Platforms

Released under the Apache 2.0 License.