I wrote an app that does something like that once, types a certain text to where the caret is, for that i used the keybd_event API(), straight forward.<br>
Now the hard part, keeping the keyboard focus in the old app when a task switch occurs, my app was on 95/98 only so i used a timer and the ThreadWalk API from the toolhelp sdk, AttachThreadInput() to every thread so that WM_SETFOCUS would have the correct hWnd in wParam (old focus) and not NULL. It's a lousy technique and I'm sure there are better ways! But I hope I atleast showed you of how NOT to do it :)<p>
Good luck