SendKeys.Send
[DllImport("user32.dll", EntryPoint = "keybd_event")]
        public static extern void keybd_event(
            byte bVk,
            byte bScan,
            int dwFlags,
            int dwExtraInfo
        );
  [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

解决方案 »

  1.   

    SendKeys..::.Send 方法  // Clicking Button1 causes a message box to appear.
    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
    MessageBox.Show("Click here!");
    }
    // Use the SendKeys.Send method to raise the Button1 click event 
    // and display the message box.
    private void Form1_DoubleClick(object sender, System.EventArgs e)
    { // Send the enter key; since the tab stop of Button1 is 0, this
    // will trigger the click event.
    SendKeys.Send("{ENTER}");
    }可能还需要用的这两个API:
    1、找到某个窗口
            [DllImport("user32.dll", EntryPoint = "FindWindow")]
            public static extern int FindWindow(
                      string lpClassName,
                      string lpWindowName
            ); 
    2、将其置顶,然后发送击键信息:
    [DllImport("user32.dll")]
    static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,int Y, int cx, int cy, uint uFlags);static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);const UInt32 SWP_NOSIZE = 0x0001;
    const UInt32 SWP_NOMOVE = 0x0002;
    const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
    //Handle是找到的窗口句柄
    SetWindowPos((IntPtr)Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);