Is there a way to access regular windows TextBox through C#?
Page 1 of 1
X_Dror




Posts: 4955
Location: Jerusalem, Israel
PostPosted: Sun, 11th May 2008 20:47    Post subject: Is there a way to access regular windows TextBox through C#?
I want to be able to access Windows' Textboxes in order to read and write data to them.
Is there any way to do this?
I want to be able to access the currently focused text box for example. If it's a notepad textbox, an Internet Explorer textbox or a word textbox as long as it is focused.

Is it possible by any way?

It should probably be pretty hard, but even the smallest thing will do.
Back to top
Rinze
Site Admin



Posts: 2343

PostPosted: Sun, 11th May 2008 21:23    Post subject:
WM_GETTEXT, SendMessage, FindWindow and related is what you want to look up for notepad. IE and Word use custom drawing for their text, so WM_GETTEXT will not work on them. Maybe hooking drawtext/textout/etc to make something generic, or possibly send ctrl-a, ctrl-c to the target window and reading the clipboard in your own app?
Back to top
X_Dror




Posts: 4955
Location: Jerusalem, Israel
PostPosted: Sun, 11th May 2008 21:31    Post subject:
How will I access these commands? Which library holds them?

Maybe reflection could do the trick? Because so far I was able to read text through reflection, but will I be able to write data through it too?

Ctrl-a, ctrl-c could can also do the trick. Got any idea on how can I access them?
Back to top
LeoNatan
Banned



Posts: 73193
Location: Ramat Gan, Israel 🇮🇱
PostPosted: Sun, 11th May 2008 21:42    Post subject:
These are API commands if I'm not mistaken, so you'll need .NET wrappers for them. Read about DllImportAttribute in MSDN.

I'm not sure that those are the commands you need though. Can you give me a more specific purpose? I will try to look for it myself, and if I can't find anything, I'll ask a lecturer the day after tomorrow.
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group