Marginally off-topic, but it is COM, and the programs involved are office programs (even if not Office programs
In an excursion back into the dinosaur years, I was reminded that IBM made its (pretty cool) LotusSmartSuite99
available for free.
The Lotus documentation itself available wasn't very good about using COM for it, but I found some while searching for a good REXX implementation.
I settled on Open Object REXX
. To my delight, I found some OLE samples right under the prog directory, some of them for WordPro.
Took about ten minutes to port to AHK.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
wp := ComObjCreate("WordPro.Application")
WinGet, pid, PID, ahk_exe wordpro.exe
wp.Visible := True
wpdoc := wp.ActiveDocument
docpath := wpdoc.Path
docname := wpdoc.Name
wpdocText := wp.Text
wp.Type("This is the first paragraph entered from AutoHotkey via COM automation.[Enter]")
;wp.Type("COM automation.[Enter]") ; Although this is on another line,
; only [Enter] starts a paragraph.
wp.Type("The second paragraph will be changed in its ")
WPDocText.Font.Name := "Arial"
WPDocText.Font.Bold := True
WPDocText.Font.Italic := True
WPDocText.Font.Size := 15
;Uncomment line below to print
;wp.PrintOut(1, 1, 1, True)
Msgbox Created %docpath%\%docname%
REXX can do cool things. Here's the original REXX sample so you can see how easy REXX COM stuff should be to port to AHK: