[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
public static void PressKey(string name)
{
const int WM_SYSKEYDOWN = 0x0104;
IntPtr WindowToFind = FindWindow(null, name);
PostMessage(WindowToFind, WM_SYSKEYDOWN, ((int)Keys.M), 0);
}
Bot.PressKey("Notepad");