Пример #1
0
        public void Submit()
        {
            if (node is IHTMLFormElement)
            {
                ((IHTMLFormElement)node).submit();
            }
            else if (node is IHTMLInputElement)
            {
                string type = GetAttribute("type");
                if (type != null && ("submit".Equals(type.ToLower()) || "image".Equals(type.ToLower())))
                {
                    Click();
                }
                else
                {
                    ((IHTMLInputElement)node).form.submit();
                }
            }
            else
            {
                IHTMLFormElement form = FindParentForm();
                if (form == null)
                {
                    throw new NoSuchElementException("Unable to find the containing form");
                }
                form.submit();
            }

            parent.WaitForLoadToComplete();
        }
Пример #2
0
 void TryFillInBing(string name)
 {
     Thread.Sleep(500);
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
     {
         if (!UpdateTextInput(0, "q", name) && Tries < 6)
         {
             Tries++;
             TryFillInBing(name);
         }
         else
         {
             IHTMLFormElement form = GetForm(0);
             form.submit();
         }
     }));
 }
Пример #3
0
        // search input complete
        void Keyboard_Closed(object sender, EventArgs e)
        {
            SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
            IntPtr handle = GetForegroundWindow();

            foreach (SHDocVw.WebBrowser IE in shellWindows)
            {
                if (IE.HWND.Equals(handle.ToInt32()))
                {
                    doc = IE.Document as mshtml.HTMLDocument;
                }
            }
            if (doc != null)
            {
                // Document 속성 읽기
                Uri    uri  = new Uri(doc.url);
                String host = uri.Host;

                if (host.Contains(naver))
                {
                    //검색어 셋팅
                    IHTMLElement query = doc.getElementsByName("query").item("query", 0);
                    query.setAttribute("value", System.Windows.Clipboard.GetText());

                    //네이버검색버튼 : search_btn
                    doc.getElementById("search_btn").click();
                }
                else if (host.Contains(search_naver))
                {
                    mshtml.IHTMLElementCollection elemColl = null;
                    elemColl = doc.getElementsByTagName("button") as mshtml.IHTMLElementCollection;

                    foreach (mshtml.IHTMLElement elem in elemColl)
                    {
                        if (elem.getAttribute("class") != null)
                        {
                            if (elem.className == "bt_search spim")
                            {
                                IHTMLElement query = doc.getElementsByName("query").item("query", 0);
                                //검색어 셋팅
                                query.setAttribute("value", System.Windows.Clipboard.GetText());
                                elem.click();
                                break;
                            }
                        }
                    }
                }
                else if (host.Contains(daum) || host.Contains(google))
                {
                    IHTMLElement q = doc.getElementsByName("q").item("q", 0);
                    q.setAttribute("value", System.Windows.Clipboard.GetText());

                    IHTMLFormElement form_google = doc.forms.item(Type.Missing, 0);
                    form_google.submit();
                }

                else
                {
                    System.Windows.MessageBox.Show("naver google daum 쓰세요");
                }
            }
        }