EKey 0 Posted December 23, 2010 Hello,I imported AutoItX.dll and most of subs and functions work, but calling the ControlGetText function gives a problem. I modify the importing function this way and that way, but it doesn't work for me.Public Class AIt <DllImport("AutoItX3.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Public Shared Function AU3_ControlGetText(<MarshalAs(UnmanagedType.LPWStr)> ByVal Title As String, _ <MarshalAs(UnmanagedType.LPWStr)> ByVal Text As String, _ <MarshalAs(UnmanagedType.LPWStr)> ByVal Control As String, _ Optional ByVal ControlText As Byte = 0, Optional ByVal BufSize As Integer = 0) As String End Function end class 'calling the function: AIt.AU3_ControlSetText("", "", Ctrl, Value)Could you please advise where is the problem in code Share this post Link to post Share on other sites
Richard Robertson 187 Posted December 23, 2010 void AU3_ControlGetText(LPCWSTR szTitle, LPCWSTR szText, LPCWSTR szControl, LPWSTR szControlText, int nBufSize);This is the C++ version. You can't go changing around the return type and mistreating the parameters.Use this for VB.Net.Declare Unicode Sub AU3_ControlGetText Lib "AutoItX3.dll" (ByVal szTitle As String, ByVal szText As String, ByVal szControl As String, ByRef szControlText() As Char, ByVal nBufSize As Integer)Call it likeDim buffer(1024) As Char AU3_ControlGetText("Some Window", "", "Control ID", buffer, 1024) Share this post Link to post Share on other sites
EKey 0 Posted December 24, 2010 Thank you, Richard. It works!!! Share this post Link to post Share on other sites
Richard Robertson 187 Posted December 24, 2010 Good to know. I don't use VB.Net and was a little unsure on array declarations. Share this post Link to post Share on other sites
EKey 0 Posted December 24, 2010 Good to know. I don't use VB.Net and was a little unsure on array declarations. Finally I used the definition: <DllImport("AutoItX3.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Public Shared Sub AU3_ControlGetText(<MarshalAs(UnmanagedType.LPWStr)> ByVal Title As String, _ <MarshalAs(UnmanagedType.LPWStr)> ByVal Text As String, _ <MarshalAs(UnmanagedType.LPWStr)> ByVal Control As String, _ ByVal ControlText() As Byte, _ Optional ByVal BufSize As Integer = 1024) End Sub Although the code is quite different but your idea, Richard, was very useful. Thank you again. Share this post Link to post Share on other sites