Please help how to use Autohotkey Functions in VBA

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
ocnuybear
Posts: 8
Joined: 15 Jul 2018, 12:52

Please help how to use Autohotkey Functions in VBA

24 Jul 2018, 01:06

Hi All,

I'm new to Autohotkey and want to use it to send keys to an inactive window.

The script below does exactly what I need.

Code: Select all

settitlematchmode,2
controlsend,,{Escape down}{Escape up}, VLC
But can I call these functions from Excel VBA using COM connection to Autohotkey?

If so what I have tried is to first register the 32 bit autohotkey.dll which registered correctly.

But as soon as I try using the VBA code:

Code: Select all

Sub atest()
Dim AHK As Object
Set AHK = CreateObject("AutoHotkey.Script")
AHK.ahktextdll ("MsgBox Hello World!" & Chr(13) & "ExitApp")
End Sub
VBA complains about activex controls.

Can anyone help me please?
ocnuybear
Posts: 8
Joined: 15 Jul 2018, 12:52

Re: Please help how to use Autohotkey Functions in VBA

27 Jul 2018, 13:15

I have added the 32 bit autohotkey.dll to the VBA reference, but it is still not working
ocnuybear
Posts: 8
Joined: 15 Jul 2018, 12:52

Re: Please help how to use Autohotkey Functions in VBA

28 Jul 2018, 13:44

I downloaded this file: ahkdll-v1-release-master.zip and used the dll from Win32a dir
ocnuybear
Posts: 8
Joined: 15 Jul 2018, 12:52

Re: Please help how to use Autohotkey Functions in VBA

28 Jul 2018, 13:53

I just tried the one in v2 & it also gives the same error
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Please help how to use Autohotkey Functions in VBA

28 Jul 2018, 15:35

Try using win32w, I will test on monday at work as I don't have office at home.
Are you trying to do that in excel?
ocnuybear
Posts: 8
Joined: 15 Jul 2018, 12:52

Re: Please help how to use Autohotkey Functions in VBA

29 Jul 2018, 01:25

I want to use it in Excel, but the main reason is to understand loading the autohotkey DLL & how to call it's functions from other programs like VBA.

Is the autohotkey a native DLL using the stdcall calling convention?

The reason I ask is DLL's created in Dot Net are managed DLL's and some 3rd party software cannot use it.

I'm new to the DLL loading concept, but have intermediate experience in different programming languages - especially automation.

Update: 30 Jul 2018

Just tried the DLL from win32w, but same error - I used different win10 pc, registered the dll with regsvr32.exe d:\AutoHotkey.dll and also added it to VBA reference
ocnuybear
Posts: 8
Joined: 15 Jul 2018, 12:52

Re: Please help how to use Autohotkey Functions in VBA

03 Aug 2018, 08:40

Can anyone give feedback please?

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 5 guests