我建议你先发送给自已的程序试试,
起码自已窗口的句柄是对的
你要确保窗口句柄是正确的你可以用findWindow或FindWindwoEx找到窗口的句柄
可能你是取到的句柄不对,你可用getwindowText Api 试一下句柄是否正确

解决方案 »

  1.   

    [DllImport("user32")] 
    public static extern unsafe int FindWindow(string sClassName,string WindowName); 
    [DllImport("user32")] 
    public static extern unsafe bool SetForegroundWindow(int hWnd);private bool AppActivate(string sWindowName)
    {
    int hwind = FindWindow(null,sWindowName);
    if (hwind == 0)
    return false;
    SetForegroundWindow(hwind);
    return true;
    }if (AppActivate("notepad")) 
    {
    System.Windows.Forms.SendKeys.SendWait("%(f)o");
    ....
    }将notepad最小化,可以发送。
      

  2.   

    谢谢,你的办法是可以正常运行的。但用这个办法就必须先把记事本放到前台来,这样对正在进行操作的有影响的~,我想用sendmessage就是认为它可以直接向最小化的程序发送消息的~不知道是不是我的理解错误,该函数不能进行这种操作?