I don''t know how much this will help, but you may want to
try SendMessage() instead of PostMessage().
PostMessage() sends a message to the queue where it simply
waits to be processed.
SendMessage() translates the message and calls the message
handler immediately.
Also, if you want a specific input to correspond to a number
of keystrokes, you might be able to use the message handler
directly.
The handler is usually made into a big switch statement so
you should be able to clump the input and the specific
keyboard messages.
Also again, Windows tells your program that a key has been hit.
Not the other way around unless your program doesn''t have a
specific way to deal with that message so it uses a default
handler.
Finally, the foreground window, whatever it is will have to know
what to do with the message when it gets it, I don''t know if
one program can send messges to another though.