有可能是接收消息程序更新了。使用SendMessage或PostMessage替代sendkey,sendkey调试的时候容易死机,而且接收的窗口还必须在最前面。//向指定句柄发送关闭消息
    [DllImport("user32.dll", EntryPoint = "PostMessage", SetLastError = true)]
    extern static bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);/// <summary>
    /// 向指定窗口发送字符串
    /// </summary>
    [DllImport("User32.dll", EntryPoint = "SendMessage")]
    static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, string lParam);    /// <summary>
    /// 该函数将指定的消息发送到一个或多个窗口。
    /// 此函数为指定的窗口调用窗口程序,直到窗口程序处理完消息再返回。
    /// 而函数PostMessage不同,将一个消息寄送到一个线程的消息队列后立即返回
    /// </summary>
    [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)]
    static extern int SendMessage(IntPtr hwnd, uint wMsg, uint wParam, uint lParam);

解决方案 »

  1.   

    可以用sendkey.send发送消息到打开的记事本,看看能不能成功,如果成功,则说明是接收消息的程序更新了,如果不能成功,电脑又要安装360,那就只能用替代方法了如果接收消息的程序能找到句柄,就用SendMessage或PostMessage没有句柄就用sendinputhttp://www.cnblogs.com/szyicol/archive/2010/05/26/1744579.html#1837094