What is DllCall in Autohotkey?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

What is DllCall in Autohotkey?

10 Oct 2016, 12:48

I know many people have asked this question in forum. But I do not really understand the dllcalls in autohotkey even after reading documentation of dllcall and reading the tutorials like this https://autohotkey.com/board/topic/8831 ... essagebox/
Please make me understand dllcalls in simple way. Also tell me how can we use this in simple codes. I will be very thankful to you.
Thanks a lot...
I don't normally code as I don't code normally.
Ronins
Posts: 85
Joined: 02 Oct 2013, 11:38

Re: What is DllCall in Autohotkey?

10 Oct 2016, 13:33

Every Operating System exposes some kind of functions which other applications can use. Applications can make a "Native call" to those functions. They are generally exposed in the form of library functions (DLL in case of windows). Many applications do this too. They expose some commonly used functions. This helps applications to be modular in nature. You can say that an entire working application might contain several individual modules (which might be in the form of DLLs).

Now, since these functions are exported to DLLs, we can use these functions by importing them and making a call to those functions. That's what DllCall does. Here's an example.

Code: Select all

DllCall("MessageBox","Uint",0,"Str","This Message is poped through DLLcall","Str","I typed that title","Uint","0x00000036L")
MessageBox is a function present in user32.dll. That DLL is preloaded in AHK, so we can call functions as shown above.
Now, as any regular function, this MessageBox function has some parameters
MSDN link shows us that the function looks like

Code: Select all

MessageBox(owner, text, caption, type)
These functions are written in strictly typed language (in simple terms, you have to ensure each parameter has correct type).
Therefore, we marshall
- owner as an unsigned integer (0 means no owner)
- the text as a string
- Caption as string
- type as unsigned integer (written as Long hex in the example above)

TL;DR - DLLs are libraries which may expose some functions which can be used by other applications. DllCall helps you call those functions.
Try out CMD class
stretchymantis
Posts: 10
Joined: 13 Nov 2021, 22:24

Re: What is DllCall in Autohotkey?

05 May 2022, 13:12

Ronins wrote:
10 Oct 2016, 13:33
@Ronins, That was an incredibly awesome explanation and helped me immensely. Thank you!!!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 176 guests