Beispiel #1
0
        public static void AutoComplete(DriveInfo foundDrives)
        {
            try {
                SHDocVw.ShellWindows sws = new SHDocVw.ShellWindows();

                foreach (SHDocVw.InternetExplorer iw in sws)
                {
                    //MessageBox.Show(iw.LocationURL);
                    if (iw.LocationName == "微博-随时随地发现新鲜事" && iw.LocationURL.Contains("weibo.com"))
                    {
                        //MessageBox.Show(doc.DomDocument.ToString());
                        mshtml.HTMLDocument doc = (mshtml.HTMLDocument)iw.Document;
                        //MessageBox.Show(doc.body.toString());
                        //HtmlDocument d = new HtmlDocument();
                        //d.Load(doc.documentElement.innerHTML);
                        //MessageBox.Show((doc.getElementsByName("username").length.ToString()));
                        var ih = new IniFiles(foundDrives.RootDirectory + "\\" + "Sec.ini");
                        NameValueCollection Values = new NameValueCollection();
                        ih.ReadSectionValues("Blog", Values);
                        ((HTMLInputTextElement)(doc.getElementsByName("username").item(0))).value = Values["User"];
                        ((HTMLInputTextElement)(doc.getElementsByName("password").item(0))).focus();
                        ((HTMLInputTextElement)(doc.getElementsByName("password").item(0))).value = Values["Pwd"];
                        //((HTMLButtonElement)doc.getElementById("btn_login")).click();
                    }
                }
            }
            catch (Exception exception) {
                MessageBox.Show(exception.Message);
            }
            //MessageBox.Show(winTxt);
        }
Beispiel #2
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("youtube.com"))
                {
                    //검색어 셋팅
                    IHTMLElement q = doc.getElementsByName("search_query").item("search_query", 0);
                    q.setAttribute("value", System.Windows.Clipboard.GetText());

                    doc.getElementById("search-btn").click();
                }
                else
                {
                    System.Windows.MessageBox.Show("이곳은 유튜브가 아닙니다.");
                }
            }
        }
Beispiel #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 쓰세요");
                }
            }
        }