|
-
Oct 3rd, 2006, 04:00 PM
#1
Thread Starter
Frenzied Member
How to read text from text box in external app?
I already have the code which finds a particular application that is running and uses sendkeys to manipulate it and get to a specific screen within the application. Once on this particular screen, there is a textbox that immediately gets the focus and is highlighted. I want to be able to read that text value within code. Any example of how to do this would be appreciated.
-
Oct 3rd, 2006, 04:14 PM
#2
Re: How to read text from text box in external app?
you'd send a WM_GETTEXT message to the window handle which you'd get with FindWindowEx API if you search the forum for that message or that API then you'll find lots of examples.
-
Oct 3rd, 2006, 05:17 PM
#3
Thread Starter
Frenzied Member
Re: How to read text from text box in external app?
I have done a search but can't really find anything for the situation that I have. Basically, I have a situation where I need to read the text out of the second text box on a form, or the text box that currently has the focus. None of the sample code allows you to read the text that is currently in focus or selected.
-
Oct 3rd, 2006, 07:06 PM
#4
Hyperactive Member
Re: How to read text from text box in external app?
simple example
VB Code:
Private Sub Form_Load()
Debug.? GetText(Text1.hwnd)
End Sub
'gets the text of a textbox or a caption of most controls
Public Function GetText(ByVal pHwnd As Long) As String
Dim Buffer As String, TextLength As Long
TextLength = SendMessage(pHwnd, WM_GETTEXTLENGTH, 0&, 0&)
Buffer = String$(TextLength, 0&)
Call SendMessage(pHwnd, WM_GETTEXT, TextLength + 1, Buffer)
GetText = Buffer
End Function
-
Oct 3rd, 2006, 07:10 PM
#5
Hyperactive Member
Re: How to read text from text box in external app?
now that i read you'r 2nd post, you're wanting your code to read the text from the textbox thats in focus?
-
Oct 3rd, 2006, 07:40 PM
#6
Thread Starter
Frenzied Member
Re: How to read text from text box in external app?
 Originally Posted by Billy Conner
now that i read you'r 2nd post, you're wanting your code to read the text from the textbox thats in focus?
Yes, exactly. How can that be done?
-
Oct 3rd, 2006, 08:08 PM
#7
Hyperactive Member
Re: How to read text from text box in external app?
i assume your using sendkeys to 'navigate' this app thru its process, is it picking a random textbox on the current form, or how is that working?
you can always use the GetFocus API call to get the current control that has focus.
-
Oct 4th, 2006, 02:12 AM
#8
Hyperactive Member
Re: How to read text from text box in external app?
if it's selected, can't you simply send a "Ctrl-C" to copy it to the clipboard?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|