C# question

Started by
3 comments, last by Martee 16 years, 2 months ago
How can I read text from a textbox or smth like that from another application. Tell me if u didn't get the idea.
Advertisement
You could use Spy++ to get the Window Handle of the edit control.
Then something like this should work:

TextBox test = Control.FromHandle(<HWND you found via Spy++>) as TextBox;
//do something with test.Text
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.
You can use

textbox.text to stock in a string

example :

string mytext = "";

mytext = textbox.text;

So simple :)
Quote:Original post by Maldus
You can use

textbox.text to stock in a string

example :

string mytext = "";

mytext = textbox.text;

So simple :)


That is indeed simple. It's also not what he's trying to do :)
To read the text from a control in another application, you will have to use P/Invoke to send a WM_GETTEXT message to the control with SendMessage() or PostMessage(). You will need to know the handle of the control; this can be obtained using Spy++ (nice and easy, for testing purposes), or using some combination of FindWindow()/EnumChildWindows()/etc.

SendMessage at pinvoke.net

ReactOS - an Open-source operating system compatible with Windows NT apps and drivers

This topic is closed to new replies.

Advertisement