Build in function, similar to DllCall but works with DllCall structures and uses Object syntax. It is often faster than DllCall, easier to use and it saves a lot of typing and code.
OutputVar := DynaCall("DllFile\Function", "ParameterDefinition", Default1, Default2, Default3, ...)Function Example: TrueSleep := DynaCall("kernel32\Sleep", "ui", 100) Calling the Func: TrueSleep[1000], %TrueSleep%(1000)
The name of the variable in which to store the DynaCall object which is used to call the dll function.
The DLL or EXE file name followed by a backslash and the name of the function. For example: "MyDLL\MyFunction" (".dll" is default and can be omitted). If an absolute path isn't specified, DllFile is assumed to be in the system's PATH or A_WorkingDir.
DllFile may be omitted when calling a function that resides in User32.dll, Kernel32.dll, ComCtl32.dll, or Gdi32.dll. For example, "User32\IsWindowVisible" produces the same result as "IsWindowVisible".
If no function can be found by the given name, a "W" (Unicode) suffix is automatically appended. For example, "MessageBox" is the same as "MessageBoxW".
This parameter may also consist solely of an an integer, which is interpreted as the address of the function to call. Sources of such addresses include COM and Callback.
For definition you will need to use the short version of DllCall types.
DllCall | DynaCall equivalent |
Int | i |
Str | s |
AStr | a |
WStr | w |
Short | h |
Char | c |
Float | f |
Double | d |
PTR | t |
Int64 | i6 |
CDecl | Use == instead of =, for example "t==uis". |
U prefix and * or p | This is supported as well, for example: "ui=ui*s", "ui=uips" |
The syntax for parameter definition is [ Return type =[=]
]
ParamType ParamType ParamType
...
You can have any amount of space or tabs between parameters, those will
be simply ignored.
Changing
order of parameters
This is best explained in following example.
AHKCMD:=DynaCall("SendMessage", ["t=tuitt", 3], A_ScriptHwnd, 0x111)
MsgBox % A_IsSuspended
AHKCMD[ 65305 ] ; suspend script, following is the same call:
; DllCall("SendMessage", "PTR", A_ScriptHwnd, "UInt", 0x111, "PTR", 65305, "PTR", 0)
MsgBox % A_IsSuspended
The default value to use when the parameter is omitted in function call.
Note, this will be always the original order of parameters as specified in
ParameterDefinition.
Base and __Class are properties and DynaCall cannot be invoked using them as parameter with dot (.) syntax, instead use MyDynaCall["base"] syntax!
AHKCMD:=DynaCall("SendMessage", ["t=tuitt", 3], A_ScriptHwnd, 0x111) ; define a DynaCall object. AHKCMD[ 65305 ] ; call the actual function AHKCMD.65305 %AHKCMD%(65305)