如何找到IE11对话框中的Hednd of SaveAs按钮

时间:2014-07-10 07:01:03

标签: c# sendmessage user32

我正在使用WatIn我登录.....下载点击,此后我有下载功能,但只有当窗口没有被激活时才能正常工作。所以我想改变.Invoke()到User32 SendMessage()因为它可以工作,即使窗口被拉扯,但为此我需要Hwnd of saveAs按钮或如果任何人知道另一种方式点击它我将非常高兴。

我的代码(只有按下按钮的功能)没有看到所有代码的共鸣

          public static void ClickSaveAs(AutomationElement mainWindow, AutomationElementCollection dialogElements, string filename)
                {
                    foreach (AutomationElement element in dialogElements)
                    {

                        if (element.Current.Name.Equals("Save"))
                        {
  AutomationElementCollection dialogSubElements = element.FindAll(TreeScope.Children, Automation.ControlViewCondition);
                            InvokePattern clickPatternForSaveDropdown = (InvokePattern)dialogSubElements[0].GetCurrentPattern(AutomationPattern.LookupById(10000));



    //here i trying to to find Hwnd of save button 
    //But i think there is way to take Hwnd  from  clickPatternForSaveDropdown                      
     IntPtr BtnTest = FindWindowEx(BtnFatherTest2, 0, "Button", "");
     IntPtr BtnTest2 = FindWindowEx(BtnFatherTest, 0, "", "Save");

     int intRes1 = SendMessage(BtnTest2 , WM_LBUTTONDOWN, 0, 0);
     System.Threading.Thread.Sleep(100);
     intRes1 = SendMessage(BtnTest2 , WM_LBUTTONUP, 0, 1);


     clickPatternForSaveDropdown.Invoke();//here the Invoke that click on button

        }
    }

    }

0 个答案:

没有答案