Link to home
Start Free TrialLog in
Avatar of gawacha1
gawacha1Flag for India

asked on

How to access textarea of MS Notepad using vb.net?

How to access text-area of MS Notepad using vb.net?
SOLUTION
Avatar of Rainverse
Rainverse

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gawacha1

ASKER

Dear Idle_Mind

here we're sending the text from Form1.Textbox1 to notepad.
I want to do it from KeyDown, say
rt=Richtextbox1
rt.SelectionStart = rt.SelectionStart - 3
                        rt.SelectionLength = 3

rt.SelectedText = ""
rt.SelectedText = "abc" ' abc are Unicode characters

I understand it is possible to send chars to notepad thro SendInput only, but is there some way to access textarea of notepad/ winword directly

Regards
SendInput() simply injects keystrokes into the stream.  Whatever application happens to be in the foreground will get them and process them as normal.  Thus you can't target the textarea of notepad/winword directly with SendInput().  To target them directly requires an approach like I've outlined above.
Dear Idle_Mind

Sorry to have used name notepad etc. what i want is target foreground application directly without using SendInput.
The keystroke has to go directly to  window after character replacement through my application. In your code i write in my application and then press button to send it to foreground window. Also your code is not working with Unicode. Is this possible.

Regards
Hmmm....the advantage of Sendkeys() is that it targets the active foreground window without requiring knowledge of what that application is, or requiring any window handles.

Given any foreground window, though, it's impossible to know whether keystrokes should be sent directly to the main window handle or if they need to be sent directly to a child window (like with Notepad).  Thus with SendMessage() and sending keys directly to a window, that approach should be used for specific situations and not a general approach for all applications.
my question remains - Send any-which-way to foreground window by a single key-press 'sequence of 3 Unicode characters'

please give sample code

regards