giorget Posted August 28, 2007 Share Posted August 28, 2007 As in precedent post i'm tryng do the same of this old post, importing wingettexthttp://www.autoitscript.com/forum/lofivers...php?t10267.htmlAs this guy i always return a zero from the function. this is the API declaration of c++ AU3_API void WINAPI AU3_WinGetText(const char *szTitle, /*[in,defaultvalue("")]*/const char *szText, char *szRetText, int nBufSize);this how i import: <DllImport("Autoitx3.dll")> _ Public Shared Sub AU3_WinGetText(ByVal strTitle As String, ByVal strText As String, ByRef returntxt As String, ByVal bufsize As Integer) End Suband this is the way i call: Dim test As String AU3_WinGetText("Sapgui 640", "", test, 100)maybe something wrong in nbufsize parameter? in the pasted post they speak about using a byte array as third parameter but i always receive a zero.for test i've tried to use a normal call with referenced object (no dllimport) and works correctlyAny ideas?thanks! Link to comment Share on other sites More sharing options...
piccaso Posted August 29, 2007 Share Posted August 29, 2007 (edited) if 'test' is a string and its 100 chars long before you pass it there is nothing wrong with it try using cdecl and set charset to ansi. edit: did you call AU3_Init() on startup? Edited August 29, 2007 by piccaso CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
BobK Posted August 29, 2007 Share Posted August 29, 2007 Try using an array of byte for the buffer. Declare Sub AU3_WinGetText Lib "AutoItX3.dll" (ByVal Title As String, ByVal Txt As String, ByVal Buffer() As Byte, ByVal BufSize As Integer) Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim buff(100) As Byte Dim st As String = "" Dim i As Integer = 0 AU3_WinGetText("Untitled", "", buff, 100) Do While (buff(i) <> 0) st = st + Chr(buff(i)) i = i + 1 Loop MsgBox(st) End Sub Link to comment Share on other sites More sharing options...
giorget Posted September 3, 2007 Author Share Posted September 3, 2007 Try using an array of byte for the buffer.Declare Sub AU3_WinGetText Lib "AutoItX3.dll" (ByVal Title As String, ByVal Txt As String, ByVal Buffer() As Byte, ByVal BufSize As Integer) Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim buff(100) As Byte Dim st As String = "" Dim i As Integer = 0 AU3_WinGetText("Untitled", "", buff, 100) Do While (buff(i) <> 0) st = st + Chr(buff(i)) i = i + 1 Loop MsgBox(st) End SubIt works!!! thanks a lot....REally!! 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