Well, I need it to be application independent. By using pipes I would need to change all applications that may be targets... Which isn't feasible.

The idea is to have an application that writes to the keyboard buffer, which in turn will be understood as the application that as the focus as the input of any user that is typing the keyboard.