I have been using SendKeys.Send() & SendKeys.SendWait() to send keys to the foreground program (a program different from the application written).
I tried sending a continuous key-press by sending repeatedly the same key with a certain delay between them but the effect was not the same as a continuous keypress in that application.
My question is: How can I send a continuous key-press to a program? The effect of that keypress must be the same as pressing myself that key continuously in the application.
SOLUTION EDIT
The solution was to call the method:
[DllImport("User32.dll")]
static extern int SendMessage(IntPtr hWnd, uint wMsg, UIntPtr wParam, IntPtr lParam);
with the parameters obtained from:
public System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("process");
p[0].MainWindowHandle is hWnd
and using Spy on the window:

right clicking on a message line in Spy shows the wMsg, wParam and lParam (all 3 in hexadecimal)
SendMessage(p[0].MainWindowHandle, (uint)0x0100, (UIntPtr)0x00000041, (IntPtr)(0x001E0001));
By sending only one WM_KEYDOWN message the effect is as the key is pressed continuously. To stop the program acting as the key is continuously pressed i have to press that key on the keyboard and release it, so that WM_KEYUP is generated. Sending WM_KEYUP in the code gives an System.OverFlow "Arithmetic operation resulted in an overflow." exception. Any ideea why that might happen?
Thanks for your replies: Ation and takrl