Jump to content
Sign in to follow this  
giorget

doing the same in vb.net -dllimport wingettext

Recommended Posts

giorget

As in precedent post i'm tryng do the same of this old post, importing wingettext

http://www.autoitscript.com/forum/lofivers...php?t10267.html

As 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 Sub

and 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 correctly

Any ideas?

thanks!

Share this post


Link to post
Share on other sites
piccaso

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 by piccaso

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

Share this post


Link to post
Share on other sites
BobK

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

Share this post


Link to post
Share on other sites
giorget

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

It works!!! thanks a lot....REally!!

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  

×