By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,012 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,012 IT Pros & Developers. It's quick & easy.

Extracting Text from another Application

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <40**********@Usenet.com>, Trancedified wrote:
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


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]
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.