Jump to content

Delphi/ControlGetText Blues


kylegee
 Share

Recommended Posts

Au3_ControlGetText('Title', '', 'RichEdit20W');

When ever I try this is returns 'not enough actual parameters'.

A simular com expression also doesn't seem to work it raises an access violation.

Does anyone know why this happens?

Edited by kylegee
Link to comment
Share on other sites

Unimaginatively enough, you're not passing enough parameters to the C API function. Look at the function prototype again, think about what the function does and what the arguments might be for.

ok:

AU3_API void WINAPI AU3_ControlGetText(const char *szTitle, const char *szText, const char *szControl, char *szControlText, int nBufSize);

So, I think I understand the first three parameters, because they were outlined in the help file. But what is char *szControlText and int nBufSize.

I'm assuming:

const char *szTitle = window title

const char *szText = text to compare grap with for boolean response

const char *szControl = control id

Link to comment
Share on other sites

You have to pass a char array buffer for the dll to fill in with the data read from the control. C++ doesn't have (yes, there is a string class but it's not very good for interop) strings per se, but they are handled as arrays of an integral type (char). You need to allocate a buffer, then pass the buffer and the length of the buffer (to prevent array-out-of-bounds type problems) for the function to operate.

Link to comment
Share on other sites

You have to pass a char array buffer for the dll to fill in with the data read from the control. C++ doesn't have (yes, there is a string class but it's not very good for interop) strings per se, but they are handled as arrays of an integral type (char). You need to allocate a buffer, then pass the buffer and the length of the buffer (to prevent array-out-of-bounds type problems) for the function to operate.

Ok, you got me heading in the right direction...But I'm still geting access violations.

procedure TForm1.Button1Click(Sender: TObject);
var
Buffer: Array[ 0..2000 ] of Char;
Begin
Au3_ControlGetText('Untitled','','Edit1','Buffer',2000);
end;

^This method now runs but stills causes violation.^

procedure TForm1.Button1Click(Sender: TObject);
Begin
A.ControlGetText('Untitled','','Edit1');
end;

^This method also runs but causes the same violation.^

Thanks for the help!

Link to comment
Share on other sites

The function is expecting the address of a buffer. Not the string "buffer" (be it the name of the variable or not). You appear to be using Delphi, so figure out how to pass the address of a variable in Delphi and you'll have that.

Link to comment
Share on other sites

Finaly solved!

A: TAutoItX3;
...
chatw:= A.ControlGetText('Title of Window','text','ControlNN');

So stupid..... The center 'text' input can not be blank '' it needs to have some of the text your trying to grab or a space if the text your grabing has spaces.

No buffering needed, chatw was declared a string.

Link to comment
Share on other sites

  • 10 months later...

Finaly solved!

A: TAutoItX3;
...
chatw:= A.ControlGetText('Title of Window','text','ControlNN');

So stupid..... The center 'text' input can not be blank '' it needs to have some of the text your trying to grab or a space if the text your grabing has spaces.

No buffering needed, chatw was declared a string.

kylegee,

I am trying to use AutoIt in delphi and am struggling with basics.

Can you please show an example of an AutoIt method definition in Delphi, and what parameter types I need to pass?

I tried:

procedure AU3_WinActivate(szTitle, szText : string); external 'AutoItX3.dll';

and

procedure AU3_WinActivate(szTitle, szText : pointer); external 'AutoItX3.dll';

and neither worked when I called with AU3_WinActivate('name', 'text');

If you have a delphi definition file you can share, what would be wonderful.

Thanks in advance.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...