AHK and .DLL files

.DLL are dynamic library files, that can be read by multiple executables all at the same time, reducing overhead.

So you could put all your functions in a .DLL file and call them from all your other scripts, thereby keeping all your functions in one place.

this seems a good path to explore now that AHK v2 is function oriented, as you are calling functions, so the scripts just make the call to the .DLL file.

I think you have to compile the .DLL file and I can’t see any vids showing VS code doing that.

Renaming .ahk2 to .dll

I tried taking functions from a .ahk2 file and just renaming extensions then using #DllLoad but that wasn’t recognised

Next using  DllCall(“[DllFile\]Function”,[ Type1, Arg1, Type2, Arg2, “Cdecl ReturnType”]) but only with DllCall(“[DllFile\]Function”) as DllCall(“Calendar.dll/DestroyCalendar()”) and that didn’t work, then went back to using:

#include Calendar.ahk2 and calling the function which is in that file and it worked fine.

So I’m not quite getting the .dll benefits here at the moment.

Maybe its good to use the windows .NET .Dll files to get things out of them, such as time and state and window id inf, although a lot of those seem to have an AHK function already such as %A_ScriptDir% which it must get from Windows somewhere.

DLL for dummies

This seems to be what I was looking for, but it only works in AHKv1, if I compile some AHK2 files to .DLL and then try using DllCall() that doesn’t seem to work.

I’ve yet to compile a v1 and test it with v1, as you need to use the DllRead( Var, “AHKFiles.dll”, “Files”, “license.txt” ) function instead, that will only run in AHK1.

DLL only in C or C# or C++?

It seems you can do icon files and call them from a Dll but not much else. There is resource hacker shown in a AHK Glines talk but that is only for icos so it doesn’t meet my need.

I think just a # include is the way to go and having different functions.

Videos on DLL calls

The video below is one of 3 about DLL calls, it all seems too painful for what was achieved. Maybe the example was too trivial but there was an awful lot of searching docs to get the bits that you want.

It was an interesting video tutorial and the chap definitely knew his stuff, but I’d need to be in real difficulties to use it.

End comment

After doing some preliminary exploration into DLL files it sees that AHK has been compiled to a DLL file , so it can bew accessed from a lot of different places all at once, I’ll think about how useful that is. I suppose you can make calls to it from a compiled AutoHotKey file for extra bits, but then all of that is compiled inside the script, so I need to do a bit more exploring on that.

It seems DLL files are .NET stuff for C# and other programs to write and compile. Not AHK.

In the glienes video they put .ico files into a .DLL for access, but they were static image files, so a library , not a program or function.

So you can call the .DLL files from AHK but you can’t make AHK DLLfiles.

So this gives you access to data in DLL files, so allows you access to a lot of windows code for other things.

As you are working with other languages you have to partially code in those languages to get the data that you want and then transfer it to AHK to use. All a bit complicated really.

For simply raiding the windows .ico files there is no issue but for other stuff it may not be worth it. AHK may not be the way to go.

There is not that much on the forum about it so I think I’ll leave it for now.