postmessage to a process

498 views Asked by At

I have a problem with posting a message to a process. When I send a key like A it is working great, but when I am sending a "special character" like Enter or F3 it is not working.

Here is my code :

[DllImport("user32.dll")]
private static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

public IntPtr SendKeystroke(IntPtr hWnd, Keys k)
{
     return PostMessage(hWnd, 0x100, (IntPtr)k, (IntPtr)0);
}

And here is executing a method :

Process p = Process.GetProcessesByName("name")[0];
SendKeystroke(p.Handle, Keys.A);
SendKeystroke(p.Handle, Keys.Enter);
0

There are 0 answers