Is there any way (Win32API or other) to get the text from any type of window? I can get the HWND of the active window, but calling sending a WM_GETTEXT message doesn’t always give me the text (MS Word being a good example).
I am trying to make a universal spellchecker, where from any application, the user presses a hotkey combination and gets corrections to his text.
Is it different if I want the whole text, just selected text, or say the word where the cursor is?
I can accept answers in c, c++, or c# using libraries or the Win32API or anything else. If there is a solution, but only in some other programming language (not likely that this can be done only in Delphi and not c with the API, but whatever), I can probably manage that as well.
Is there any way (Win32API or other) to get the text from any type
Share
You’re not going to be able to do this without referencing application-specific APIs. Different applications handle text differently.
In Notepad, for example, the text is just a string in a multiline text-box which the Windows API can retrieve.
Word, however, handles the text internally and renders the display as an image. All the Windows API knows about is the bitmap rendered by Word. There’s no way for the Windows API to get at the ASCII/Unicode characters that make up the text. For this you need to use Word’s API. Many other applications will present the same problem.