Autohotkey library supports DllCall()
and it can call dll with standard decl
feature of c dll. However, typical c# library runs on IL
and cannot be called from autohotkey. To support standard dll call, DllExport
package is required in Visual Studio.
The name will be automatically set to the namespace.
make sure that namespace is the same as your project's namespace
Custom function should be statc
, to be exported using DllExport
, or it emits error during build process
// class1.cs
namespace myDll
{
public class Class1 // this class name doesn't matter
{
[DllExport]
public static double mySum(double x, double y)
{
return x + y;
}
}
}
You can check path of resulting dll file at console output.
If you are in x64 machine, get dll file in the x64 folder!! ex:
C:\Users\Eli\Downloads\EliDll\myDll\myDll\bin\Release\x64\myDll.dll
; main.ahk
; This file calls mysum function in myDll.dll
; and put double 5 and double 4 as input args and get output with double type.
; Be careful of case-sensitive function name and arg type
; See more info about syntax at https://www.autohotkey.com/docs/commands/DllCall.htm
result:=DllCall("myDll.dll\mySum", "Double", 5, "Double", 4,"Double")
MsgBox, %result%