日期:2014-05-17  浏览次数:21283 次

SendMessage 发送按钮点击事件 按钮没响应
c#程序给另一个C#程序发送按钮点击事件的时候按钮是有相应的。
可是给其他的一个第三方程序发送按钮点击事件的时候,按钮就没有相应了。按钮的句柄这些都用spy++查看了,没有问题,有谁知道这可能是什么方面的原因吗?

            string aDir = @"D:\gc\Tonsinsoft\MultiTax\Mtdeclare.exe";
            ProcessStartInfo aStartInfo = new ProcessStartInfo();
            aStartInfo.CreateNoWindow = true;
            aStartInfo.FileName = aDir;
            aStartInfo.UseShellExecute = true;
            aStartInfo.WorkingDirectory = @"D:\gc\Tonsinsoft\MultiTax";
         
            System.Diagnostics.Process.Start(aStartInfo);

            Thread.Sleep(1000);

            ParenthWnd = FindWindow("TLoginDialog", null);

            ////用户名
            ParenthWnd_sub = FindWindowEx(ParenthWnd, EdithWnd, "TRzEdit", "");
            SendMessage(ParenthWnd_sub, WM_SETTEXT, (IntPtr)0, this.txtName.Text.Trim());

            ////密码
            ParenthWnd_sub = FindWindowEx(ParenthWnd, ParenthWnd_sub, "TRzEdit", "");
            SendMessage(ParenthWnd_sub, WM_SETTEXT, (IntPtr)0, this.txtPsw.Text.Trim());

            //确定按钮
            ParenthWnd_sub = FindWindowEx(ParenthWnd, (IntPtr)0, "TRzBitBtn", "登录(&O)");
            SendMessage(ParenthWnd_sub, WM_CLICK, 0, 0);