Skip to content

Instantly share code, notes, and snippets.

@tinku99
Created September 8, 2011 15:24
Show Gist options
  • Save tinku99/1203668 to your computer and use it in GitHub Desktop.
Save tinku99/1203668 to your computer and use it in GitHub Desktop.
call entrypoint in a .net assembly from autohotkey
c# =
(
using System.Windows.Forms;
using System.Windows.Automation;
public class Foo {
public static void Main() {
MessageBox.Show("hello from Foo entrypoint");
}
public void Test() {
MessageBox.Show("Hello from nonentrypoint");
}
}
)
c#2 =
(
using System.Windows.Forms;
using System.Windows.Automation;
using System.Reflection;
using System ;
using System.Threading;
public class Bar {
Assembly asm ;
public static void Main() {
MessageBox.Show("hello from Bar entrypoint");
}
public Assembly Test2() {
asm = Assembly.LoadFrom("Foo.exe");
Thread t = new Thread(new ThreadStart(test3));
t.Start();
MessageBox.Show("Hellow from Bar after launching Foo thread, ");
return asm ;
}
public void test3(){
Object[] Args = new Object[0];
asm.EntryPoint.Invoke(null, Args);
}
}
)
CLR_Start()
CLR_StartDomain(pApp, A_WorkingDir)
CLR_CompileC#(c#, "System.dll | System.Windows.Forms.dll | C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\UIAutomationClient.dll", pApp, A_ScriptDir . "\Foo.exe")
CLR_CompileC#(c#2, "System.dll | System.Windows.Forms.dll | C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\UIAutomationClient.dll"
, pApp, A_ScriptDir . "\Foo2.exe")
asm2 := CLR_LoadLibrary("Foo2.exe", pApp)
obj2 := CLR_CreateObject(asm2, "Bar")
asm := COM_Invoke(obj2, "Test2")
msgbox % "back in ahk with Foo still running, will now call Test in foo "
obj := CLR_CreateObject(asm, "Foo")
COM_Invoke(obj, "Test")
COM_Release(obj2)
COM_Release(asm2)
COM_Release(obj)
COM_Release(asm)
return
#include clr.ahk
#include com.ahk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment