Пример #1
0
        private void webView_LoadCompleted(object sender, NavigationEventArgs e)
        {
            WebBrowser web = (WebBrowser)sender;

            //HTMLDocument htmldocument = (HTMLDocument)web.Document;
            mshtml.HTMLDocument dom = (mshtml.HTMLDocument)web.Document; //定义HTML
            //dom.documentElement.style.overflow = "hidden"; //隐藏浏览器的滚动条
            //dom.body.setAttribute("scroll", "no"); //禁用浏览器的滚动条
            dom.getElementById("inputText").innerText = "Исключение, которое выбрасывается, в случае возникновения ошибки при работе с сетью.";
            dom.getElementById("translateBtn").click();

            //task2.Wait(1000);
            Thread.Sleep(1000);

            var    s      = web.DataContext;
            string result = dom.getElementById("translateBtn").outerHTML.ToString();

            httpListenner(dom);

            //webView_DataContextChanged
            //if (!dom.body.innerHTML.Contains("123456"))
            //{
            //    string szTmp = "http://192.168.0.11/sample2.htm";
            //    Uri uri = new Uri(szTmp);
            //    CamWeb.Navigate(uri);
            //}
        }
Пример #2
0
        private void webView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            WebBrowser web1 = (WebBrowser)sender;

            mshtml.HTMLDocument dom2 = (mshtml.HTMLDocument)web1.Document; //定义HTML
            string       result      = dom2.getElementById("outputText").outerText;
            IHTMLElement element     = dom2.getElementById("outputText");
        }
Пример #3
0
        //해당 ID와 PW로 로그인하기
        public void loginMethod()
        {
            dataGridView1.ClearSelection();

            dataGridView1.Rows[nextRowIndex].Selected = true;

            string id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
            string pw = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();

            inputId(id);
            inputPassword(pw);

            mshtml.HTMLDocument dd = ie.Document;
            var divs = dd.getElementsByTagName("div");

            foreach (IHTMLElement div in divs)
            {
                string divInnterHtml = div.innerText;
                if (divInnterHtml != null && divInnterHtml.Equals("로그인"))
                {
                    Console.WriteLine("로그인 버튼 클릭");
                    div.click();

                    Thread.Sleep(5000);

                    mshtml.HTMLDocument dda = ie.Document;

                    var alertP = dda.getElementById("slfErrorAlert");

                    if (alertP == null)
                    {
                        //로그인 성공

                        FileStream fileStream = new FileStream(filePath, FileMode.Append, FileAccess.Write);

                        string       strData      = id + " " + pw;
                        StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.UTF8);
                        streamWriter.WriteLine(strData);
                        streamWriter.Close();

                        fileStream.Close();
                        return;
                    }
                    //else
                    //{
                    //    FileStream fileStream = new FileStream(filePath, FileMode.Append, FileAccess.Write);

                    //    string strData = id + " " + pw;
                    //    StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.UTF8);
                    //    streamWriter.WriteLine(strData);
                    //    streamWriter.Close();

                    //    fileStream.Close();
                    //    //로그인 실패
                    //    return;

                    //}
                }
            }
        }
        /// <summary>
        /// When the button is clicked, it will execute the Exec method of the
        /// IOleCommandTarget interface.
        /// </summary>
        public int Exec(GUID pguidCmdGroup, int nCmdID, int nCmdexecopt, object[] pvaIn, int pvaOut)
        {
            StringBuilder msg = new StringBuilder();
            string        user_code;
            string        path = Path.GetTempPath() + "merlin.txt";

            using (StreamReader sr = File.OpenText(path))
            {
                user_code = sr.ReadLine();
            }
            mshtml.HTMLDocument    doc            = ieInstance.Document as mshtml.HTMLDocument;
            IHTMLElementCollection head_collect   = doc.all.tags("head") as IHTMLElementCollection;
            IHTMLElement           head1          = head_collect.item(null, 0) as IHTMLElement;
            IHTMLScriptElement     script_Element = doc.createElement("script") as IHTMLScriptElement;

            script_Element.type = "text/javascript";
            script_Element.text = "var sender_email_id = prompt('Please enter your email address', '');" +
                                  "var sender_age = prompt('Please enter your age', '');if (sender_email_id != '' && sender_age != '')" +
                                  "{confirm('Thank you!');var mesg = 'age_group: ' + sender_age + ' ' + 'email_id: ' + sender_email_id;document.getElementById('age_email').value=mesg}";
            string asp = "<input type='hidden' id='age_email' value=''>";

            doc.body.insertAdjacentHTML("afterBegin", asp);
            ((HTMLHeadElement)head1).appendChild((IHTMLDOMNode)script_Element);
            var mesg = doc.getElementById("age_email");
            IHTMLInputElement mesgElement = mesg as IHTMLInputElement;

            send_data         = mesgElement.value + ' ' + user_code;
            websocket         = new WebSocket("ws://merlin.ece.ufl.edu:8080/events/");
            websocket.Opened += new EventHandler(websocket_Opened);
            websocket.Open();

            return(0);
        }
Пример #5
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("이곳은 유튜브가 아닙니다.");
                }
            }
        }
Пример #6
0
        private void Web_LoadCompleted(object sender, NavigationEventArgs e)
        {
            WebBrowser web = (WebBrowser)sender;

            //HTMLDocument htmldocument = (HTMLDocument)web.Document;
            mshtml.HTMLDocument dom = (mshtml.HTMLDocument)web.Document; //定义HTML
            //dom.documentElement.style.overflow = "hidden"; //隐藏浏览器的滚动条
            //dom.body.setAttribute("scroll", "no"); //禁用浏览器的滚动条
            dom.getElementById("inputText").innerText = "Исключение, которое выбрасывается, в случае возникновения ошибки при работе с сетью.";
            dom.getElementById("translateBtn").click();
            task2.Wait(1000);
            m_SyncContext.Post(lable1, "task2 执行ing" + ((int)(stopwatch.ElapsedMilliseconds)).ToString());
            string result = dom.getElementById("translateBtn").outerHTML.ToString();

            httpListenner(dom);



            //   var  ElementCollection =( (HTMLDocument)web.Document).getElementsByTagName("Table");
            //foreach (  item in ElementCollection)
            //{
            //    File.AppendAllText("Kaijiang_xj.txt", item.InnerText);
            //}
        }
        private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
        {
            try
            {
                if (!webBrowser1.Source.IsFile)
                {
                    mshtml.HTMLDocument doc = (mshtml.HTMLDocument)webBrowser1.Document;
                    if (doc != null)
                    {
                        string docurl = doc.url;
                        if (docurl.Contains("TravelCard/TravelCard"))
                        {
                            string html = "";
                            html                       = doc.body.innerHTML;
                            this.htmlString            = html;
                            this.partid                = "";
                            this.NumofContinuationOMIs = 0;
                            string part = null;

                            part = doc.getElementById("partnum").innerText;
                            if (part != "" && part != null)
                            {
                                this.partid = part;
                            }
                            string numofcards = "";
                            //TODO: change the name of this span to something more meaningful.
                            numofcards = doc.getElementById("Span4").innerText;

                            //  numofcards = "0";

                            if (numofcards != null && numofcards != "")

                            {
                                this.NumofContinuationOMIs = Convert.ToInt16(numofcards);
                            }
                            else
                            {
                                this.NumofContinuationOMIs = 0;
                            }
                            this.partid.Trim();
                            if (this.partid.Length > 0)
                            {
                                Mouse.OverrideCursor   = Cursors.Wait;
                                webBrowser1.Visibility = Visibility.Hidden;
                                OMIPrint();
                                btnPrintFiles.Visibility = Visibility.Visible;
                                btnPrintFiles.IsEnabled  = true;
                                btnPrintFiles.Background = System.Windows.Media.Brushes.Orange;
                                btnPrintFiles.Foreground = System.Windows.Media.Brushes.Black;
                                btnPrintFiles.Content    = "Print all docs for part #" + this.partid;
                                if (this.redlightgreenlightfilepath != "" || this.redlightgreenlightfilepath != null)
                                {
                                    btnPrintRedLight.Visibility = Visibility.Visible;
                                    btnPrintRedLight.Background = System.Windows.Media.Brushes.Green;
                                }
                                webBrowser1.Visibility = Visibility.Visible;
                                string pdfpath = System.Configuration.ConfigurationManager.AppSettings["pdfWorkFilePath"].ToString();
                                webBrowser1.Navigate(new System.Uri(pdfpath + this.partid.Trim() + "Merged.pdf"));
                                Mouse.OverrideCursor = null;
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
Пример #8
0
        public void WebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            //throw new NotImplementedException();
            mshtml.HTMLDocument           doc  = webBrowser.Document as mshtml.HTMLDocument;
            mshtml.IHTMLElementCollection coll = (mshtml.IHTMLElementCollection)(doc.getElementsByTagName("button"));
            mshtml.IHTMLElement           coll_id_start_explorer = (mshtml.IHTMLElement)(doc.getElementById("id_start_explorer"));
            mshtml.IHTMLElement           coll_id_start_dialog   = (mshtml.IHTMLElement)(doc.getElementById("id_start_dialog"));

            // https://codevomit.wordpress.com/2015/06/15/wpf-webbrowser-control-part-2/

            /*
             * foreach (mshtml.IHTMLElement obj in coll)
             * {
             *  HTMLButtonElementEvents_Event htmlButtonEvent = obj as HTMLButtonElementEvents_Event;
             *  htmlButtonEvent.onclick += clickElementHandler;
             * }
             * //*/

            if (coll_id_start_dialog != null)
            {
                HTMLButtonElementEvents_Event htmlButtonEvent = coll_id_start_dialog as HTMLButtonElementEvents_Event;
                htmlButtonEvent.onclick += start_dialog;
            }
            if (coll_id_start_explorer != null)
            {
                HTMLButtonElementEvents_Event htmlButtonEvent = coll_id_start_explorer as HTMLButtonElementEvents_Event;
                htmlButtonEvent.onclick += start_explorer;
            }
        }
Пример #9
0
        private void Webbrowser_LoadCompleted(object sender, NavigationEventArgs e)
        {
            try
            {
                if (!_isRun && _isLoginAttempt)
                {
                    // Get the website document first
                    mshtml.HTMLDocument document = (mshtml.HTMLDocument)Webbrowser.Document;

                    // Set the username
                    var username = document.getElementById("ap_email");
                    if (username != null)
                    {
                        username.innerText = _username;
                    }
                    // Now for amazon we need to click first
                    var theElementCollection = document.getElementsByTagName("input");
                    if (theElementCollection != null)
                    {
                        foreach (var el in theElementCollection)
                        {
                            if (((HTMLDTElement)el).id == "continue")
                            {
                                ((HTMLDTElement)el).click();
                            }
                        }
                    }

                    // Let the page load
                    System.Threading.Thread.Sleep(2000);

                    // Get the newly loaded document
                    document = (mshtml.HTMLDocument)Webbrowser.Document;

                    // Fill in password
                    var pw = document.getElementById("ap_password");
                    if (pw != null)
                    {
                        pw.innerText = ByteHelper.ByteArrayToString(CryptMemoryProtection.DecryptInMemoryData(_encryptedPassword));
                    }

                    theElementCollection = document.getElementsByTagName("input");
                    if (theElementCollection != null)
                    {
                        // Click login button
                        foreach (var el in theElementCollection)
                        {
                            if (((HTMLDTElement)el).id == "signInSubmit")
                            {
                                ((HTMLDTElement)el).click();
                            }
                        }
                    }

                    Navigation_Textblock.Text = Webbrowser.Source.AbsoluteUri;
                    _isRun = true;
                }
            }
            catch (Exception ex)
            {
                Communication.InformUser("Couldn't log into page.");
                Logger.log.Error($"Couldn't login to page: {ex}");
                Close();
            }
        }
Пример #10
0
 private void Button_Click_8(object sender, RoutedEventArgs e)
 {
     msl = (mshtml.HTMLDocument)Webbrowser1.Document;
     msl.getElementById("keyword1").setAttribute("value", SelectSTR.Text);
     Webbrowser1.InvokeScript("eval", "document.getElementById('searchbtn1').click()");
 }