kylegee Posted January 21, 2008 Share Posted January 21, 2008 (edited) 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 January 21, 2008 by kylegee Link to comment Share on other sites More sharing options...
Valik Posted January 21, 2008 Share Posted January 21, 2008 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. Link to comment Share on other sites More sharing options...
kylegee Posted January 21, 2008 Author Share Posted January 21, 2008 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 titleconst char *szText = text to compare grap with for boolean responseconst char *szControl = control id Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 21, 2008 Share Posted January 21, 2008 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 More sharing options...
kylegee Posted January 21, 2008 Author Share Posted January 21, 2008 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 More sharing options...
Valik Posted January 22, 2008 Share Posted January 22, 2008 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 More sharing options...
kylegee Posted January 23, 2008 Author Share Posted January 23, 2008 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 More sharing options...
Richard Robertson Posted January 24, 2008 Share Posted January 24, 2008 I don't have a clue how you could ever get that to work. Link to comment Share on other sites More sharing options...
Valik Posted January 24, 2008 Share Posted January 24, 2008 Simple, that's the COM interface which returns the string as opposed to the C interface which requires an output buffer. Link to comment Share on other sites More sharing options...
toga1 Posted December 13, 2008 Share Posted December 13, 2008 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now