Jump to content
Sign in to follow this  

[Solved]Wanted DLL callback example - C++ & Autoit code

Recommended Posts


I wish to convert my Mouse & Keyboard capture autoit source code into a DLL so that I can lock the DLL into monitoring only the events for it's parent autoit process (i.e. prevent the code from being used as a keylogger).

Once done - I then should be able to post this on the forum so that it can be used by the community.

I have never coded in C++.

I am good at taking examples and extending them to meet my requirements.

I have working examples for autoit calling functions in a C++ dll I have created.

However, I do not have a working example of an autoit function being called from the dll (via DllCallbackRegister).

The example(s) I have found on the forum are incomplete.

Could someone be kind enough to create a share a simple DLL that calls back an autoit function (source code of both - I assume all I need is the .h, .cpp & .au3 source)

Many thanks in advance

Edited by MouseSpotter

Share this post

Link to post
Share on other sites

Found a working example:

The code I used was


#define DECLDIR __declspec(dllexport)
extern "C"
   DECLDIR void OnAutoItFunc(void * func);


#include "basicdll.h"
extern "C"
  typedef int (_stdcall * au3_func)(int,int,int);
void _cdecl OnAutoItFunc(void * func) {
  int ret = 0;
  if(func) {
   au3_func MyAu3Func = (au3_func) func;
   ret  = MyAu3Func(10,20,30);


$dll = DllOpen( path  to basicdll.dll)
Func Myau3Func($a, $b, $c)
ConsoleWrite("Myfunc called with a = " & $a & " b = " & $b & " c = " & $c & @LF)
Return $a + $b + $c
$cb = DllCallBackRegister("Myau3Func","int","int;int;int")
$pcb = DllCallBackGetPtr($cb)
DllCall($dll, "none:cdecl", "OnAutoItFunc","ptr",$pcb)

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...