ComDispatch by fincs (based on my DispatchObj) and modified by Coco:
- Requires defining which methods can be called, and it only supports methods, not properties.
- Objects need to be explicitly wrapped before passing them to a COM API.
- Objects need to be explicitly unwrapped when they are returned from a COM API.
So I experimented with adding native support for passing AutoHotkey objects to/from COM APIs. The cost is about 1-2KB of added size to AutoHotkey.exe (32-bit), with the following features:
- No wrapper objects; AutoHotkey objects implement IDispatch natively, though it is never used by AutoHotkey itself.
- Supports calling methods and getting/setting properties.
- Supports calling functions (by reference).
- All types of AutoHotkey objects can be passed to COM APIs.
- COM objects must still be wrapped, since they don't support the interface used internally by AutoHotkey.
- AutoHotkey objects passed back from COM APIs are recognized automatically and not wrapped in a ComObject.
- Enumeration is not supported.
- ByRef is not supported (except via a ComObject wrapper).