open the editor, set cursor to any place (or select some text), and run the code:
fn myAssembly =
(
source = ""
source += "using System;
"
source += "using System.Runtime.InteropServices;
"
source += "public class MyOps
"
source += "{
"
source += " [DllImport(\"user32.dll\")]
"
source += " public static extern int SendMessage(Int32 hWnd, int wMsg, int wParam, [MarshalAs(UnmanagedType.LPStr)] string lParam);
"
source += "}
"
csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.ReferencedAssemblies.Add "System.dll"
compilerParams.GenerateInMemory = on
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
(compilerResults.CompiledAssembly).CreateInstance "MyOps"
)
global ops = if ops == undefined then myAssembly() else ops
(
fn _mxs_Textbox =
(
tb = for c in (windows.getchildrenhwnd 0) where c[4] == "MXS_SciTEWindow" do exit with
(
for t in (windows.getchildrenhwnd c[1]) where t[4] == "MXS_Scintilla" do exit with t[1]
)
if tb != ok then tb else undefined
)
if (tb = _mxs_Textbox()) != undefined do
(
EM_REPLACESEL = 0xC2
any_text = "\"Hello World!\""
-- Insert Text or Replace Selection:
ops.SendMessage tb EM_REPLACESEL 1 any_text -- 1 means to make it undoable
)
)
PS. I didn’t clean it up! Use at your own risk!