Page 1 of 1

Autohokey.dll v1 from Powershell

Posted: 22 Aug 2022, 14:30
by newvice
Im looking for a way to execute my scripts without using the exe. Plan is to use the AHK_H (v1) DLL from powershell and let it exec my scripts/code.

I downloaded the release from github and had a look at the exported functions of Autohotkey.dll. My assumption was that the DLL would have the AHK functions like send, sendplay, imagesearch, etc. Seems like it only has function to execute AHK code. Anyway not relevant.

Can someone please help me with getting this to run via powershell or at least tell me what function of the DLL to use and what the parameters are (I should be able to do the DllImport from Powershell)? It's stated no where.

Also can use the DLL without running regsvr? That would be important too.

Thanks

Re: Autohokey.dll v1 from Powershell  Topic is solved

Posted: 23 Aug 2022, 05:25
by newvice
download the relase from github. there youll find folders fpr x86 and x64 version. I used wx64 withput mt. copy the dll from there.

no regsrv required

this is for starting scripts:

Code: Select all

$MethodDefinition = @'

[DllImport("C:\\Users\\XXXDocuments\\XXX\\XXX\\XXX\\XXX\\AutoHotkey.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "ahkdll")]
public static extern int ahkdll(string scriptFilePath, string parameters = "", string title = "");

'@

$ahk = Add-Type -MemberDefinition $MethodDefinition -Name 'ahk' -PassThru

$ahk::ahkdll("C:\Users\XXX\Documents\XXX\XXX\XXX\XXX\test.ahk")
this is for executing ahk commands as strings:

Code: Select all

$MethodDefinition = @'

[DllImport("C:\\Users\\XXX\\Documents\\XXX\\XXX\\XXX\\XXX\\AutoHotkey.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "ahktextdll")]
public static extern int ahktextdll(string script, string parameters = "", string title = "");

'@

$ahk = Add-Type -MemberDefinition $MethodDefinition -Name 'ahk' -PassThru

$ahk::ahktextdll("msgbox hello")