Much more robust way is sending it via Windows API
SendInput
, see
http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx[
^]. This method closely simulates physical keyboard. At the same time, it is much easy to use correctly; it does not require tricky calculation of message parameters (
lParam
is especially tricky, easy to make a mistake).
Please try — it works well.
—SA