in the win32 api you use the SendInput() api to simulate keystrokes or mouse-events. This will send the event to the active window, whatever process owns it. You can also use SendMessage to send keystrokes to a particular window, but you would need the window handle to be able to do that.
Here is an example in C that waits 5 seconds, then sends a bunch of keystrokes to whatever happens to be the active window at the time.
---------------
#define _WIN32_WINNT 0x500
#include
#include
#include
void main(int argc, char* argv[])
{
INT nCount;
Sleep(5000);
INPUT arInput[26];
for (nCount = 0; nCount < 26; nCount++)
{
CHAR cKey = 'A' + nCount;
INT nKey = cKey - 'A' + 65;
arInput[nCount].type =INPUT_KEYBOARD;
arInput[nCount].ki.wVk = nKey;
arInput[nCount].ki.time = 0;
arInput[nCount].ki.wScan = 0;
arInput[nCount].ki.dwExtraInfo = 0;
arInput[nCount].ki.dwFlags = 0;
}
SendInput(26,arInput,sizeof(INPUT));
}
--------------