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.
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!
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 ?
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.
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.
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...
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.
Re: How I can get the text of a textbox that is on other app?
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?
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.
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
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.
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!