Convert .ahk to .dll Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ceyhunveysel
Posts: 52
Joined: 02 Aug 2019, 15:39

Convert .ahk to .dll

07 Dec 2019, 19:36

Hello.
I am trying to make one of my .ahk libraries, but it doesn't work. It gives me an error saying I can't open the file.
Is there a program that will make me compile an .ahk to a .dll?
Thanks
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Convert .ahk to .dll

07 Dec 2019, 19:50

In AutoHotkey_H you can compile your script using AutoHotkey.dll.
After loading it you will need to run ahktextdll or ahkdll without script parameter.
ceyhunveysel
Posts: 52
Joined: 02 Aug 2019, 15:39

Re: Convert .ahk to .dll

08 Dec 2019, 06:13

Sorry, I didn't include what I meant in my message.
Here's what I'm saying:

I actually made a library about 1~3 days ago, but I want to compile my library to .dll and make sure ahk understands it.
I tried to make my lib .dll, but it didn't work.
So I'm saying;
Is there a ".ahk to .dll" compiler?
signature C:
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Convert .ahk to .dll

08 Dec 2019, 08:11

I think what you need is the resourcelibrary in AutoHotkey_H.
Download ResourceHacker and check LIB resources in AutoHotkey.exe, the same way you can add your resource libraries.
Hese are default libraries included: https://github.com/HotKeyIt/ahkdll/tree/master/source/resources/reslib

Other than that AHK cannot load libraries from dll.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Convert .ahk to .dll

08 Dec 2019, 10:59

i too have a hard time following what ure saying
u made a library(in what language) that u need "ahk to be able to understand"

it sounds like u wrote something in c and ure asking how to compile it into a dll, but i cant be too sure
ceyhunveysel
Posts: 52
Joined: 02 Aug 2019, 15:39

Re: Convert .ahk to .dll

08 Dec 2019, 19:08

I made a file that helps my script, made by the language AutoHotkey.
I want to Compile my library to a .dll, but when I #include it, it would be readable by AutoHotkey.
signature C:
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Convert .ahk to .dll

09 Dec 2019, 00:38

#include only reads text files
why do you want to compile it to .dll?

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Convert .ahk to .dll

09 Dec 2019, 04:57

so u have a .ahk library(containing god knows what... functions presumably, but not necessarily) that u want to compile into a .dll, and then u want to load the now compiled .dll library back into ahk? why? what is the need for this backasswards approach?

as for how to do it: u write a C wrapper, calling the ahk functions(with ahk_h's autohotkey.dll), u compile it into a .dll, u write an .ahk wrapper, which loads the .dll in(and other required dependencies), retrieves the function pointers of the C wrapper functions(which themselves wrap ahk functions) and calls them. finally, u #include the ahk wrapper

...
ceyhunveysel
Posts: 52
Joined: 02 Aug 2019, 15:39

Re: Convert .ahk to .dll

09 Dec 2019, 05:35

Ok, Jesus, I'm giving up!
signature C:
just me
Posts: 9527
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Convert .ahk to .dll

09 Dec 2019, 05:41

ceyhunveysel wrote: So I'm saying;
Is there a ".ahk to .dll" compiler?
AFAIK, no!
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Convert .ahk to .dll

09 Dec 2019, 06:46

¯\_(ツ)_/¯
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Convert .ahk to .dll

09 Dec 2019, 14:51

just me wrote:
09 Dec 2019, 05:41
ceyhunveysel wrote: So I'm saying;
Is there a ".ahk to .dll" compiler?
AFAIK, no!
Yes there is, in AHK_H.
But there is no way to use #include myahkdll.dll.
But there is AhkThread that can load the dll and the script can call the functions in that dll.
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Convert .ahk to .dll

10 Dec 2019, 07:19

ceyhunveysel wrote:
07 Dec 2019, 19:36
Hello.
I am trying to make one of my .ahk libraries, but it doesn't work. It gives me an error saying I can't open the file.
Is there a program that will make me compile an .ahk to a .dll?
Thanks
I'm a bit confused by what you are doing. Maybe so are others. Did you write the code that you want to compile into a .dll, in the AutoHotkey language, or some other programming language? If you wrote the code in AutoHotkey, you can do what HotKeyIt has recommended, including also using #Include (https://www.autohotkey.com/docs/commands/_Include.htm). AutoHotkey programs with the .ahk extension can call functions from other .ahk labelled files, using #Include with the name and location of that file. If you are compiling your .ahk file into .exe, then you can use FileInstall (https://www.autohotkey.com/docs/commands/FileInstall.htm) to make sure the .ahk files you are calling functions from are included.

If you wrote the code in a different programming language, you can compile it into a .dll with that language, then possibly call it with AutoHotkey using DllCall() (https://www.autohotkey.com/docs/commands/DllCall.htm).

As HotKeyIt has described, AutoHotkey_H gives you additional options as well.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Convert .ahk to .dll

10 Dec 2019, 07:47

I feel that this topic is filled with misunderstanding

Im not sure if OP really has a need for a dll

as to me it seems that he just wishes to include some other ahk code he made

but his attempt to use include have not worked so he now believes that he needs to make it in to a dll

OP that is not how you do that in AutoHotkey

Something that can help to clear up misunderstandings like this is to post your code, both the code (script) you wish to include and the code (script) you with to include it in...
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
ceyhunveysel
Posts: 52
Joined: 02 Aug 2019, 15:39

Re: Convert .ahk to .dll

10 Dec 2019, 16:01

OK! Goddamnit! I'm gonna explain this ONE MORE TIME and the FINAL TIME.

I've made an AutoHotkey script, that I will include on one of my OTHER scripts.
But I want to compile my FIRST script to a .dll and #Include it in one of my scripts, but AHK would understand the FIRST script I created and load it's functions when I call them.

PLEASE like PLEASE say you understood that. FFS.
signature C:
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Convert .ahk to .dll

10 Dec 2019, 16:44

But I want to compile my FIRST script to a .dll and #Include it in one of my scripts
Simple, you don't need to compile it:

Code: Select all

; Your other script in that file starts from first line and can call functions from other script...
Return ; end of the other script to make sure it does not fall trough to the FIRST script

; FIRST.ahk needs to be in same directory, see help file for options
#include FIRST.ahk
ceyhunveysel
Posts: 52
Joined: 02 Aug 2019, 15:39

Re: Convert .ahk to .dll

11 Dec 2019, 16:36

compile it as a .dll
I said that I would compile it as a .dll.
Hope you got it.
signature C:
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Convert .ahk to .dll

11 Dec 2019, 19:11

still hasn't answered swagfag's question: why?

HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Convert .ahk to .dll

12 Dec 2019, 12:14

I have the perfect solution :D
1. Rename your mylibrary.ahk file to mylibrary.dll
2. Then use #include mylibrary.dll

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CoffeeChaton and 100 guests