Isn't there any programmatic way of doing this?
Anybody has any suggestions?
Main Topics
Browse All TopicsHow to get all text left of cursor from inside current active window.
For example, all the text that is currently typed inside MSWord or notepad or search box inside firefox!
From within my application I want to read all the text that is currently present inside current active window.
GetForegroundWindow()->Get
is returning text of title bar but not contents of a window!
Any suggestions on this...
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I tried the code below, but no use. Any suggestions on the piece of code below.
m_predListViewer->m_curHwnd
in the TCHAR variable 'a' below I am not getting any result. Just the junk values put during initialization remains.
Do you get a valid response to the WM_SETSETLENGTH, and does the control you are reaching support the GETTEXT command ?
In other words, GETTEXT does not work in all situations, and there are circumstances in which you *cannot* get ant text from child windows (Windows created by Java -bypassing Win API- are an example).
It would work in Notepad, but not in MS Word not any WebBrowsers.
I checked the Delphi Code (after correcting a minor error on line 13; chaged the -1 to 0), and it does read the text from NotePad.
Don't have a compiler to check your code. Can you take a look at the hFocus value to make sure that correspond to the right Window (Use winSight or Spy++)
Its seems there is no direct way of getting text from current active window. An indirect way exists which is to, select all contents of current active window, copy them to clip board and and read the clipboard.
This can be seen in the below post.
http://www.experts-exchang
Business Accounts
Answer for Membership
by: ahalyaPosted on 2008-08-04 at 19:55:31ID: 22157781
You need to find the handle of the child window that has he focus (a Edit, Button, ComboBox etc) and then call GetWindowText with that handle.
This will give you the "caption" of that window. (In the case of EDIT boxes/Combo Boxes it will be the text. (Now, to get the text left of cursor would be a more difficult task).