Autohokey.dll v1 from Powershell Topic is solved

Ask for help, how to use AHK_H, etc.
newvice
Posts: 24
Joined: 12 Jun 2021, 09:20

Autohokey.dll v1 from Powershell

22 Aug 2022, 14:30

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
Last edited by newvice on 23 Aug 2022, 14:09, edited 2 times in total.
newvice
Posts: 24
Joined: 12 Jun 2021, 09:20

Re: Autohokey.dll v1 from Powershell  Topic is solved

23 Aug 2022, 05:25

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")

Return to “Ask for Help”

Who is online

Users browsing this forum: No registered users and 92 guests