Windows has an entire API for text input and interaction.
The Text Services Framework (TSF) is a COM framework and API that supports advanced text input and text processing. It is designed to offer advanced language and word processing features to applications. It supports features such as multilingual support, keyboard drivers, handwriting recognition, speech recognition, as well as spell checking and other text and natural language processing functions.
The diagram is below but please see the details at http://msdn.microsoft.com/en-us/library/ms538050(VS.85).aspx
TSF can be implemented as an app or as a text service.
For a keyboard, we’d be writing a TSF text service.
On the app side, extensibility is done by the app by implementing interfaces and registering them with TSF.
TSF can read the current "context" from the application, which . The "context" is the characters on the screen around the insertion point.
TSF and Managed Code: Difficult since text service gets loaded into arbitrary processes, so they need to be small and lightweight, among other reasons. http://blogs.msdn.com/tsfaware/archive/2007/04/19/tsf-and-managed-code.aspx
Legacy apps: TSF has a table of controls for legacy apps that describes the input scope (e.g. the address bar control in IE5 takes a “url”)
Other notes: The Tablet PC TIP uses TSF to provide text to apps.