Sign in to follow this  
Followers 0
dddienst

Creating and passing a class as a DLL Param

4 posts in this topic

Ok, I am trying to evaluate the Screen OCR SDK and I am having some trouble because the primary function I want to call in there DLL needs to be passed a pointer to a class. I can see that AutoIt supports DLL Calls and even some support for creating Structures to pass to DLL functions but how do I Create load and pass a class?

Here is a snipit from the header file they give to use with the DLL.

class TextractSource {
 public:
  TextractSource();
  TextractSource& BmpFile(const char *bmpFileName);
  TextractSource& Wnd(HWND);
  TextractSource& Rect(int ax, int ay, int bx, int by);
  TextractSource& DesktopWnd();
  TextractSource& TopWnd(const char *windowClass, const char *windowText);
  TextractSource& DeepWnd(const char *windowClass, const char *windowText);
  TextractSource& SubWnd(const char *windowClass, const char *windowText);
  TextractSource& SubDeepWnd(const char *windowClass, const char *windowText);
  TextractSource& FindLargestWindow();

  const char *BmpFileName; // used if != NULL
  HWND W; // used if != NULL
  int AX, AY, BX, BY; // used if BmpFileName == NULL and Wnd == NULL
};

TextractExport TextractSuccess Textract(TextractSource&, TextractDest&, 
  TextractDestFormat);

I have only included one class for brevity but TextractDest is also a class. TextractSuccess is just a long.

Thanks,

dddienst

P.S. I see many here prefer to use Tesseract but I am using Win7 which that has trouble with so I wish to try this method. OR would it be better to use VB and access both AutoIt and ScreenOCR with COM interfaces since both also have support for that method. I just don't what to make things more complex then they need to be. :)

Share this post


Link to post
Share on other sites



$tTextractSource = DllStructCreate("ptr BmpFileName;hwnd W;int AX;int AY;int BX;int BY;")
$pTextractSource = DllStructGetPtr($tTextractSource)
$aRes = DllCall("dllname.dll", "int:cdecl", "Textract", "ptr", $pTextractSource, "ptr", $pTextractDest)

Several things are assumed here: TextractSuccess is an enumeration (int), that class is a simple one, no polymorphism is involved and that the calling convention is __cdecl. Change the necessary fields.

Share this post


Link to post
Share on other sites

Change the necessary fields

???? I am also struggling with this since 2 days. :D

but cannot make it work.

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

Share this post


Link to post
Share on other sites

+1

I'm also confused by this. Dont know how to return the recognized data to text at all.

Plz any help is greatly appreciated!

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