Sign in to follow this  
Followers 0
BitRot

Letting a DLL call-back a AI-function.

11 posts in this topic

Hello All,

I would like to be able to use a DLL-function that needs to do a "Call-back".

The problem is that I have absolutily no idea if that is possible, and if it is how to convert an AI-function address into one that a DLL-function understands.

I remember VB had something like an "AddressOf" operator, which would probably suit my needs.

A related problem : A call-back function is mostly executed with a number of "simple" arguments on the stack. Those arguments need ofcourse allso be converted into something AI can handle.

Any ideas ?

By the way : the function I'm talking about is "EnumChildWindows"

Share this post


Link to post
Share on other sites



Take a look at AutoItX

Just did, and its a bit ... overwhelming. Could you be a bit more specific, like which one of those calls (under "DLL Interface" -> "Function Prototypes C" I should look at, and how I get to the real information (such as how to define & use it) ? (Or if thats the wrong location, where else to look)

Thanks.

Share this post


Link to post
Share on other sites

you cant call a autoit function from the outside

but you can use windows messaging.

check the helpfile for GUIRegisterMsg


CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

Share this post


Link to post
Share on other sites

you cant call a autoit function from the outside

:ph34r: That's not really what I hoped to hear :lmao:

but you can use windows messaging.

check the helpfile for GUIRegisterMsg

I just took a look at both "GUIRegisterMsg" and "EnumChildWindows", but do not see a method, using AI's own commands, to convert to the output of the latter so that it can be transferred by the first. Any hints ?

Share this post


Link to post
Share on other sites

here is an example using WM_COPYDATA

if you tell me what the message looks like i can tell you how to decode it...

the easiest way would be a ptr to a struct so you can use DllStruct* functions to access it.

if its just a null terminated string you want to read from memory, i can give you this

sligtly modified function i made for the sqlite3.dll wrapper i wrote (see sig)...

Func _szStringRead($iszPtr, $iLen = -1)
    Local $aStrLen, $vszString
    If $iszPtr < 1 Then Return ""
    If $iLen < 0 Then
        $aStrLen = DllCall("msvcrt.dll", "int", "strlen", "ptr", $iszPtr)
        If @error Then Return SetError(1, 0, "")
        $iLen = $aStrLen[0] + 1
    EndIf
    $vszString = DllStructCreate("char[" & $iLen & "]", $iszPtr)
    If @error Then Return SetError(2, 0, "")
    Return SetError(0, $iLen, DllStructGetData($vszString, 1))
EndFunc   ;==>_szStringRead

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

Share this post


Link to post
Share on other sites

here is an example using WM_COPYDATA

Thanks, but I don't think that is what I'm looking for. What I'm looking for is a method that makes it possible for an AI-function to be called by a DLL-function.

None-the-less, thanks for trying (I did put those two scripts in my "could be interresting" -repository :lmao: )

Share this post


Link to post
Share on other sites

There has already been some work done with EnumChildWindows, including callbacks:

http://www.autoitscript.com/forum/index.php?showtopic=32077

There's more if you search the forum...

Thanks for the link. :lmao: I allready was afraid that it would need a user-written DLL to be able to do it. And you're right, I should have searched the fora first. For some reason I did not even think of it. :ph34r:

Share this post


Link to post
Share on other sites
Here is the response I got when I asked the question.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Here is the response I got when I asked the question.

Short, and crystal-clear. :lmao: Edited by BitRot

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0