|
-
Sep 4th, 2006, 07:46 PM
#1
Thread Starter
Junior Member
How I can get the text of a textbox that is on other app?
Hi all.
(windows forms).
How I can get the text of a textbox that is on other app?
Example:
I have an app running that has a textbox which Text property is "MICROSOFT VISUAL STUDIO ROCKS!".
I want to make an application that will obtain the handle of that textbox and get its contents (its text property value). I already have the code that obtain the handle.
I think that I need to use WM_GETTEXT in conjunction with OpenProcess, WriteProcessMemory, SendMessage and ReadProcessMemory. But I have no idea how to do it.
Please help me.
Thx in advance.
Best regards,
Marco Alves.
-
Sep 4th, 2006, 08:57 PM
#2
Lively Member
Re: How I can get the text of a textbox that is on other app?
In order to do that, I alway follow step by step :
1. Find Handle of window which you want to hook
2. Find Handle of Textbox in this window you've founded
3. Then, SendMessage TextBoxHandle, WM_GETTEXT,0,0 to get content of this TextBox
Good luck!
!Have fun!

-
Sep 5th, 2006, 06:33 AM
#3
Thread Starter
Junior Member
Re: How I can get the text of a textbox that is on other app?
sorry for my ignorance, but I think that this don't work across process boundaries. can you help ?
-
Sep 5th, 2006, 06:47 AM
#4
Lively Member
Re: How I can get the text of a textbox that is on other app?
Oh, I think you should google to "Hooking and Subclassing in VB" , this ebook would be useful for you.
You can post your simple code? I need to know more about your project.
!Have fun!

-
Sep 5th, 2006, 07:55 PM
#5
Re: How I can get the text of a textbox that is on other app?
WM_GETTEXT is OK across process boundaries.
AFAIK any message below WM_USER can be used across processes because the OS will handle transferring the data for you.
-
Sep 6th, 2006, 07:02 AM
#6
Thread Starter
Junior Member
Re: How I can get the text of a textbox that is on other app?
I will post my code here to you see it and help me...
-
Sep 6th, 2006, 07:48 AM
#7
Frenzied Member
Re: How I can get the text of a textbox that is on other app?
Search the forums; this has been asked and answered many times.
Also look into getting patorjkapispy
very easy for things like you are doing.
Also check the API FAQs for some of my posts, i know i posted a sample project on how to send/get text from an msn window given partial window caption i believe.
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Sep 6th, 2006, 07:50 AM
#8
Frenzied Member
Re: How I can get the text of a textbox that is on other app?
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Oct 3rd, 2006, 09:19 PM
#9
Frenzied Member
Re: How I can get the text of a textbox that is on other app?
What if the textbox is on a child form within the application (not MDI) and is on a tab control? Do I need to first fine the address of the main window, then the child window, then the tab control to get to the textbox I want to read from?
-
Oct 3rd, 2006, 10:06 PM
#10
Re: How I can get the text of a textbox that is on other app?
You can use FindWindowEx to get a child window, or EnumChildWindows.
Not sure what you mean by "main window". Any window that is not enclosed within another window (as a textbox is) can be found using FindWindow.
-
Oct 3rd, 2006, 10:23 PM
#11
Frenzied Member
Re: How I can get the text of a textbox that is on other app?
Okay, I've got this working to a point. Now, on the screen where I want to read from a particular textbox, there are more than one textbox on the screen with the same Class name. How do I specify that I want to read from a certain textbox? I'm using the following code to read the text, but again, it's reading from the first textbox on the screen, I want to read from the second one.
VB Code:
If hwnd Then
'-- grab text out of textbox
hwnd2 = FindWindowEx(hwnd, 0, "Edit", vbNullString)
If hwnd2 Then
SetForegroundWindow hwnd
ret = SendMessage(hwnd2, WM_GETTEXTLENGTH, 0, 0)
buffer = Space(ret)
ret = SendMessageByString(hwnd2, WM_GETTEXT, ret + 1, buffer)
MsgBox buffer
End If
End If
-
Oct 3rd, 2006, 10:50 PM
#12
Re: How I can get the text of a textbox that is on other app?
Does it have a window name?
Otherwise, you will have to use EnumChildWindows.
-
Oct 13th, 2006, 04:41 PM
#13
Addicted Member
Re: How I can get the text of a textbox that is on other app?
Hey! Can 1 of you guyz post the whole code?
i dont understand it! But i think i am in need of it too. I dont understand all that you guyz have said much. So please post a full code that once copy pasted can work? [I]with tips please!
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
|