AutoHotkey.Interop 1.0.0.1

dotnet add package AutoHotkey.Interop --version 1.0.0.1                
NuGet\Install-Package AutoHotkey.Interop -Version 1.0.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AutoHotkey.Interop" Version="1.0.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AutoHotkey.Interop --version 1.0.0.1                
#r "nuget: AutoHotkey.Interop, 1.0.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AutoHotkey.Interop as a Cake Addin
#addin nuget:?package=AutoHotkey.Interop&version=1.0.0.1

// Install AutoHotkey.Interop as a Cake Tool
#tool nuget:?package=AutoHotkey.Interop&version=1.0.0.1                

AutoHotkey.Interop

This project is a basic wrapper around HotKeyIt's AHKDLL (aka AutoHotkey_H) for .Net Projects.

This also includes a simple communication module to allow AHK to communicate with the .NET hosting environment using a simple method SendPipeMessage(string) from AutoHotkey. see example below

This was made to be intended to use as is, without needing to register any of the com components or any other special deployment tasks. The required (AutoHotkey_H) AutoHotkey.dll can either be deployed via XCOPY or the application will automatically deploy the required AutoHotkey.dll file if it is missing, as it stores a copy as an embeded resource.

All the thanks goes to HotKeyIt's work

Usage & Examples

To use, just include my DLL and it will deploy any files that are missing if needed.

//grab a copy of the AutoHotkey singleton instance
var ahk = AutoHotkeyEngine.Instance;

//execute any raw ahk code
ahk.ExecRaw("MsgBox, Hello World!");

//create new hotkeys
ahk.ExecRaw("^a::Send, Hello World");

//programmatically set variables
ahk.SetVar("x", "1");
ahk.SetVar("y", "4");

//execute statements
ahk.ExecRaw("z:=x+y");

//return variables back from ahk
string zValue = ahk.GetVar("z");
Console.WriteLine("Value of z is {0}", zValue); // "Value of z is 5"

//Load a library or exec scripts in a file
ahk.LoadFile("functions.ahk");

//execute a specific function (found in functions.ahk), with 2 parameters
ahk.ExecFunction("MyFunction", "Hello", "World");

//execute a label 
ahk.ExecLabel("DOSTUFF");

//create a new function
string sayHelloFunction = "SayHello(name) \r\n { \r\n MsgBox, Hello %name% \r\n return \r\n }";
ahk.ExecRaw(sayHelloFunction);

//execute's newly made function\
ahk.ExecRaw(@"SayHello(""Mario"") ");


//execute a function (in functions.ahk) that adds 5 and return results
var add5Results = ahk.Eval("Add5( 5 )");
Console.WriteLine("Eval: Result of 5 with Add5 func is {0}", add5Results);

//you can also return results with the ExecFunction 
add5Results = ahk.ExecFunction("Add5", "5");
Console.WriteLine("ExecFunction: Result of 5 with Add5 func is {0}", add5Results);

//you can have AutoHotkey communicate with the hosting environment 
// 1 - Create Handler for your ahk code 
// 2 - Initalize Pipes Module, passing in your handler
// 3 - Use 'SendPipeMessage(string)' from your AHK code
var ipcHandler = new Func<string, string>(fromAhk => {
    Console.WriteLine("received message from ahk " + fromAhk);
    System.Threading.Thread.Sleep(3000); //simulating lots of work
    return ".NET: I LIKE PIE!";
});

//the initalize pipes module only needs to be called once per application
ahk.InitalizePipesModule(ipcHandler); 

ahk.ExecRaw(@"serverResponce := SendPipeMessage(""Hello from ahk"")
              MsgBox, responce from server was -- %serverResponce% ");

HotKeyIt's AutoHotkey_H Github Repository
AutoHotKey_H Dll Documentation

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.1 7,063 6/20/2021
1.0.0 386 6/20/2021

Updated AutoHotkey dlls and allowed version choosing