This should be possible using window hooks, and especially CBTProc. Here are the docs from MS:
CBTProc callback function[
^]
It might not be possible for clients which don't use GDI(+) to draw their windows (which might be true for WPF based applications, but i honestly don't know), but let's say, every application whose windows show up in a tool like SPY++ (which is part of the Microsoft Visual Studio Installation) should be able to be tracked using the hook.
There are several articles about hooking available on the web and also on codeproject itself. Maybe there's even one which comes close to what you're looking for. For example, have a look at this one:
Manipulating Windows using messages and simple CBT hooking[
^]
Using this hook, it is possible to track the active application from within another application. What's then left to do is to find a way to put the desired text into the target control. There exist several not too difficult possibilities to approach that. I haven't tested it, but using WM_SETTEXT instead of get like described
here[
^] could do the trick.
Here's an excerpt from SPY++ 64bit for an IE8 64bit instance where IEs main window handle is 001C1BBC and the one from the address combobox 00091C20.
<00069> 001C1BBC S WM_ACTIVATEAPP fActive:True dwThreadID:00000000
<00070> 001C1BBC R WM_ACTIVATEAPP
<00071> 001C1BBC S WM_NCACTIVATE fActive:True
<00072> 001C1BBC R WM_NCACTIVATE
<00073> 001C1BBC S WM_ACTIVATE fActive:WA_CLICKACTIVE fMinimized:False hwndPrevious:(null)
<00074> 001C1BBC R WM_ACTIVATE
<00075> 001C1BBC S WM_GETICON nType:ICON_SMALL
<00076> 001C1BBC R WM_GETICON hicon:7D9016F5
<00077> 001C1BBC S WM_SETCURSOR hwnd:
00091C20 nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
<00078> 001C1BBC R WM_SETCURSOR fHaltProcessing:False
<00079> 001C1BBC S WM_SETCURSOR hwnd:
001C1BBC nHittest:HTCAPTION wMouseMsg:WM_MOUSEMOVE
<00080> 001C1BBC R WM_SETCURSOR fHaltProcessing:False
<00081> 001C1BBC P WM_NCMOUSEMOVE nHittest:HTCAPTION xPos:725 yPos:47
<00082> 001C1BBC S WM_SETCURSOR hwnd:
001C1BBC nHittest:HTCAPTION wMouseMsg:WM_MOUSEMOVE
<00083> 001C1BBC R WM_SETCURSOR fHaltProcessing:False
<00084> 001C1BBC P WM_NCMOUSEMOVE nHittest:HTCAPTION xPos:751 yPos:33
<00085> 001C1BBC P WM_NCMOUSELEAVE