COM interface [v3 beta 5+]
You can interface with SciTE programmatically by using COM.
On startup, SciTE registers a COM IDispatch object under the AppID of SciTE4AHK.Application that you can retrieve using ComObjActive() or similar. Here's a sample AutoHotkey script to get the current file:
oSciTE := ComObjActive("SciTE4AHK.Application") MsgBox % oSciTE.CurrentFile
List of methods and (GET-only) properties:
Version
Gets the current SciTE4AutoHotkey version.
oSciTE.Version
SciTEHandle
Gets the HWND of the SciTE window.
oSciTE.SciTEHandle
UserDir [v3.0.01.01+]
Retrieves the user profile directory.
oSciTE.UserDir
IsPortable [v3.0.01.01+]
Gets whether the SciTE installation is portable or not.
oSciTE.IsPortable
Message()
Sends a message to either SciTE or the toolbar.
oSciTE.Message(msg [, wParam, lParam])
msg | The message number to send. |
wParam | (Optional) The wParam of the message. If omitted, defaults to zero. |
lParam | (Optional) The lParam of the message. If omitted, defaults to zero. |
If the message number is greater or equal than 0x1000, it is sent to the toolbar using PostMessage. Else, it's sent to SciTE using SendMessage.
ReloadProps()
Reloads all SciTE property files.
oSciTE.ReloadProps()
SciTEDir [v3.0.00 RC+]
Returns the SciTE4AutoHotkey installation directory.
oSciTE.SciTEDir
CurrentFile
Gets the full path of the currently active file.
oSciTE.CurrentFile
OpenFile() [v3.0.01+]
Opens a file in SciTE.
oSciTE.OpenFile(filename)
filename | The file to open. |
DebugFile()
Opens a file if necessary and starts a debugging session.
oSciTE.DebugFile(filename)
filename | The file to debug. |
Tabs
Gets a TabList object containing the filenames of all currently opened tabs:
oTabs := oSciTE.Tabs
Returns |
A TabList object: ArrayRetrieves the tab list as a SafeArray. oTabs.Array ListRetrieves the tab list as a oTabs.List CountRetrieves the number of tabs. oTabs.Count |
SwitchToTab()
Switches to the specified tab.
oSciTE.SwitchToTab(tabidx)
tabidx | Tab number (zero based). |
Document
Gets the whole text of the current file.
oSciTE.Document
Selection
Gets the current selection.
oSciTE.Selection
InsertText()
Inserts the specified text at the specified position.
oSciTE.InsertText(text [, pos])
text | The text to insert. |
wParam | (Optional) The position at which insert the text. If omitted, the current caret position is used instead. |
ActivePlatform
Gets the name of the currently selected platform.
oSciTE.ActivePlatform
SetPlatform()
Selects the current platform.
oSciTE.SetPlatform(platform)
platform | The name of the platform to set. |
SendDirectorMsg()
Sends a message to SciTE using the Director interface.
oSciTE.SendDirectorMsg(message)
message | The message to send. |
SendDirectorMsgRet()
Same as above, but allows for getting a return value.
oSciTE.SendDirectorMsgRet(message)
message | The message to send. |
Returns | A COM object with two properties: verb and value . |
SendDirectorMsgRetArray()
Same as above, but allows for getting an array as the return value.
oSciTE.SendDirectorMsgRet(message)
message | The message to send. |
Returns | A SafeArray of COM objects with two properties: verb and value . |
ResolveProp() [v3.0.00+]
Retrives the value of a property key, resolving $(dereferences) in the process.
oSciTE.ResolveProp(propname)
propname | The name of the property key to retrieve. |
Returns | The value of the property key. |
Output() [v3.0.01.01+]
Adds text to SciTE's output pane.
oSciTE.Output(text)
text | The text to add. |