Sign in to follow this  
Followers 0
BloodyKnights

Need some help with AutoItX3.dll and borland C++ Builder

2 posts in this topic

Im currently trying to move some of my previous AutoIt network admin tools over to C++. In doing so I have made a continuously developing headache. Due to the fact that some of the functionality of my previous scripts are not easy to reproduce! Every attempt to use PostMessage, SendMessage, SendInput, and keybd_event have failed to work with our in-house software. The Auto-It Send() function however does work. Ive been trying to get it to work in C++ Builder 6 for a little over a week now (Point blank, Im almost bald). If anyone has accomplished using the AutoItX3.dll inside of C++ builder can anyone please help me.

Here is what ive Tried so far with no luck!

First Attempt > LoadLibrary

(Beginning of file)

typedef  void (__stdcall *ptrFunc) (BSTR strSendText/*[in]*/, long nMode/*[in,def,opt]*/) ;

(Inside main)

HINSTANCE handle = LoadLibrary("AutoItX3.dll") ;
   Func = (ptrFunc) (GetProcAddress(handle,"Send") );
   ...
   ...
   Func(MystrSendText, 0);

Result:

Project AdminUpdates.exe raised exception class EAccessViolation with message 'Access violation at address 00000000. Read of address 0000000'. Process stopped. Use step or run to continue.

Second Attempt > AutoIt3.h ( From AutoIt3\AutoItX\StandardDLL\DevC )

(Beginning of File)

#include "AutoIt3.h"

(Inside main)

AU3_Send(MystrSendText, 0);

Result:

[Linker Error] Unresolved external 'AU3_Send' referenced from E:\[ System ]\My Documents\C++ Code\AdminUpdates\First.obj

Third Attempt > AutoItX3Lib_TLB.h ( Generated from "Import Type Library" )

Directly after generating the code it throws an Error on the second line of the following code:

__property   long            error = {read = get_error};
  __property   long            SW_HIDE = {read = get_SW_HIDE};
  __property   long            SW_MAXIMIZE = {read = get_SW_MAXIMIZE};
  __property   long            SW_MINIMIZE = {read = get_SW_MINIMIZE};
  __property   long            SW_RESTORE = {read = get_SW_RESTORE};
  __property   long            SW_SHOW = {read = get_SW_SHOW};
  __property   long            SW_SHOWDEFAULT = {read = get_SW_SHOWDEFAULT};
  __property   long            SW_SHOWMAXIMIZED = {read = get_SW_SHOWMAXIMIZED};
  __property   long            SW_SHOWMINIMIZED = {read = get_SW_SHOWMINIMIZED};
  __property   long            SW_SHOWMINNOACTIVE = {read = get_SW_SHOWMINNOACTIVE};
  __property   long            SW_SHOWNA = {read = get_SW_SHOWNA};
  __property   long            SW_SHOWNOACTIVATE = {read = get_SW_SHOWNOACTIVATE};
  __property   long            SW_SHOWNORMAL = {read = get_SW_SHOWNORMAL};
  __property   BSTR            version = {read = get_version};

[C++ Error] AutoItX3Lib_TLB.h E2040 Declaration terminated incorrectly

This error occures on every property line after that.

Note: if I comment out all property lines within the file then it works well atleast untill I get to the main code and try calling any of the functions. There not accessible, and any attempt to try and access them results in

[C++ Error] First.cpp(34):E2272 Identifier expected

[C++ Error] First.cpp(34):E2379 Statment missing ;

DLL's are not my strong suit! Ive tried every variation of the above two steps and researched google, and the forum to no avail. I have no problem with any other asspect of C++, but this problem with the DLL is driving me crazy. If anyone has been able to get this working, please let me know how I maybe able to fix this. Thanks in advance!

Share this post


Link to post
Share on other sites



Ok, umm this was my first post in the forums, and now I kind of feel DLL retarded. I got it to work thankfully.

for borland C++ builder its actually pretty simple now that I have figured it out!

1) convert the dll file to a lib useing implib (Borland\CBuilder6\Bin)

implib AutoIt3.lib C:\AutoItX3.dll

2) Add the newly created .lib file to your project

3) Copy the AutoIt3.h file to the same directory as your project (AutoIt3\AutoItX\StandardDLL\DevC)

4) include AutoIt3.h to your project

#include "AutoIt3.h"

So after all that I answered my own question! lol

Figured I'd add what I did to get it working just in case anyone ever has this same problem.

P.S. Now that I've gone bald, I can finally start growing my hair back out! lol

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