Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Extracting Text from another Application

39 views
Skip to first unread message

Trancedified

unread,
May 25, 2004, 10:01:26 AM5/25/04
to
Hello,

I read through this thread regarding FindWindowEx vs.
EnumChildWindows:
http://www.xtremevbtalk.com/showthread.php?t=130418

It looks like it was done in VB6, can this be done in VB.NET? I am
trying to extract information from a very old desktop application
that doesn't support copy/paste.

Our client doesn't want to look up the information, write down, for
example a telephone number and then open up another application and
re-enter the information in.

In the above example it shows how to send information like "Hello
World" into a textbox in another application. Can we do the opposite?
Extract information and send it to my custom application?

Thanks in advance!

Chris


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Tom Shelton

unread,
May 25, 2004, 10:59:14 AM5/25/04
to

As long as the control that has the text you want to extract the text
from has a window handle, then yes it is possible using either
GetWindowText or using SendMessage and WM_GETTEXTLENGTH and
WM_GETTEXT... After you locate the window of course :)

You can declare the functions with almost the same syntax in VB.NET -
the major difference is that the data types will be different.

For example, EnumChildWindow:

Private Delegate Function EnumChildProcDelegate _
(ByVal hWnd As IntPtr, _
ByVal lParam As Integer) As Boolean

Private Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As IntPtr, _
ByVal lpEnumFunc As EnumChildProcDelegate, _
ByVal lParam As Integer) As Boolean

Then you would have a function in your class/module/form

Private Function EnumChildProc _
(ByVal hWnd As IntPtr, ByVal lParam As Integer) As Boolean

...
End Function

You wold call EnumChildWindows like this:

' Assuming in a form, keep the delegate so GC doesn't interfer
Dim proc As New EnumChildProcDelegate(AddressOf Me.EnumChildProc)
EnumChildWindows(Me.Handle, proc, 0)

Anyway, that is just one example (and probably the hardest one to do :)
Just remember that in VB.NET the data sizes have changed, for example in
VB6 Integer is 16-bit and Long is 32-bit. In VB.NET Integer is 32-bit
and Long is 64-bit. So, basically in VB.NET you use Short where you
used Integer in VB6, Integer where you used Long (or Boolean), etc.

HTH
--
Tom Shelton [MVP]

0 new messages