AutoHotkey   COM Interface

Available Interfaces

Module AutoHotkey.exe v2 Interface GUID
All versions AutoHotkey2.Application {1EB0A161-FE26-4C22-A15D-1B6C6F2677B9}

Examples

Visual Basic example.
Sub atest()
Dim AhkCom As Object
Set AhkCom = CreateObject("AutoHotkey2.Application")
AhkCom.NewThread("MsgBox 'Hello World!'" & Chr(13) & "ExitApp")
End Sub
AutoHotkey example.
AhkCom := ComObject("AutoHotkey2.Application")
ThreadID:=AhkCom.NewThread("MsgBox 'Hello World!'`nExitApp")
While AhkCom.ahkReady(ThreadID)
  Sleep, 100
MsgBox Exiting now
AhkComObject class to implement default parameter ThreadID.
Class AhkComObject {
  __New(p*){
    this.com:=ComObject("AutoHotkey2.Application")
    this.ThreadID:=this.com.NewThread(p*)
  }
  ahkPause(Pause){
    return this.com.ahkPause(this.ThreadID,Pause)
  }
  ahkReady(var){
    return this.com.ahkRedy(this.ThreadID)
  }
  ahkFindLabel(Label){
    return this.com.ahkFindLabel(this.ThreadID,label)
  }
  ahkgetvar(var){
    return this.com.ahkgetvar(this.ThreadID,var)
  }
  ahkassign(var, value:=""){
    return this.com.ahkassign(this.ThreadID,var,value)
  }
  ahkExecuteLine(line, mode:=1, wait:=1){
    return this.com.ahkExecuteLine(this.ThreadID,line,mode,wait)
  }
  ahkLabel(LabelName, wait:=1){
    return this.com.ahkLabel(this.ThreadID,LabelName,wait)
  }
  ahkFindFunc(FuncName){
    return this.com.ahkFindFunc(this.ThreadID,FuncName)
  }
  ahkFunction(FuncName,Params*){
    return this.com.ahkFunction(this.ThreadID,FuncName,Params*)
  }
  ahkPostFunction(FuncName,Params*){
    return this.com.ahkPostFunction(this.ThreadID,FuncName,Params*)
  }
  addScript(Script,waitexecute:=0){
    return this.com.addScript(this.ThreadID,Script,waitexecute)
  }
  ahkExec(Script){
    return this.com.ahkExec(this.ThreadID,Script)
  }
}
ahk:=AhkComObject("Persistent`nvar:='testing'`nMsgBox var")
MsgBox ahk.ahkgetvar("var")
MsgBox ahk.addScript("fun(p,d){`nMsgBox p '``n' d`nreturn 'hello from ' A_ThisFunc`n}")
MsgBox ahk.ahkFunction("fun","AutoHotkey","Call function test.")