C Output to keyboard

a quick question for you:

Is it possible to send C output to keyboard? To give an example, is it possible to write a program that while is running if I leave mouse pointer on chat box writes on that chat box as if I was using the keyboard? Thanks for your answers! PS I am using Mac OS X