Ejemplo n.º 1
0
        /// <summary>
        /// Loads the anchors for a specified html file
        /// </summary>
        /// <param name="fileName">The file name in which anchors are to be retrieved from</param>
        private void LoadAnchors(string fileName)
        {
            WebClient client = new WebClient();

            byte[] data = client.DownloadData(fileName);
            mshtml.HTMLDocumentClass ms = new mshtml.HTMLDocumentClass();
            string strHTML = Encoding.ASCII.GetString(data);

            mshtml.IHTMLDocument2 mydoc = (mshtml.IHTMLDocument2)ms;
            //mydoc.write(!--saved from url=(0014)about:internet -->);
            mydoc.write(strHTML);

            mshtml.IHTMLElementCollection ec = (mshtml.IHTMLElementCollection)mydoc.all.tags("a");
            if (ec != null)
            {
                for (int i = 0; i < ec.length - 1; i++)
                {
                    mshtml.HTMLAnchorElementClass anchor;
                    anchor = (mshtml.HTMLAnchorElementClass)ec.item(i, 0);

                    if (!string.IsNullOrEmpty(anchor.name))
                    {
                        cmbAnchor.Items.Add(anchor.name);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //输入账号密码
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                mshtml.HTMLDocumentClass htmlDoc = webBrowser1.Document.DomDocument as mshtml.HTMLDocumentClass;
                object index = 0;
                mshtml.IHTMLWindow2 frameWindow = htmlDoc.frames.item(ref index) as mshtml.IHTMLWindow2;

                IHTMLDocument2 frame = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow);

                mshtml.IHTMLElementCollection logins = (mshtml.IHTMLElementCollection)frame.all.tags("input");

                mshtml.IHTMLInputElement element = (mshtml.IHTMLInputElement)logins.item("u", 0);
                element.value = "305723370";

                element       = (mshtml.IHTMLInputElement)logins.item("p", 0);
                element.value = "cdtanji51520";
            }
            catch (System.Exception _e)
            {
                Console.Write(_e.Message);
            }
        }
Ejemplo n.º 3
0
        //切换到账号输入
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                mshtml.HTMLDocumentClass htmlDoc = webBrowser1.Document.DomDocument as mshtml.HTMLDocumentClass;
                object index = 0;
                mshtml.IHTMLWindow2 frameWindow = htmlDoc.frames.item(ref index) as mshtml.IHTMLWindow2;

                IHTMLDocument2 frame = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow);

                mshtml.IHTMLElementCollection logins  = (mshtml.IHTMLElementCollection)frame.all.tags("a");
                mshtml.IHTMLElement           element = (mshtml.IHTMLElement)logins.item("switcher_plogin", 0);
                element.click();
            }
            catch (System.Exception _e)
            {
                Console.Write(_e.Message);
            }
        }
Ejemplo n.º 4
0
 private void InspectFrameMouseEvent(mshtml.IHTMLElementCollection fc)
 {
     if (fc == null)
     {
         return;
     }
     if (fc.length > 0)
     {
         for (int i = 0; i < fc.length; i++)
         {
             object                  id              = (object)i;
             IHTMLWindow2            frameWindow     = (IHTMLWindow2)fc.item(id, 0);
             mshtml.HTMLDocument     frameDoc        = (mshtml.HTMLDocument)frameWindow.document;
             mshtml.DispHTMLDocument frameDispDoc    = (mshtml.DispHTMLDocument)frameDoc;
             DHTMLEventHandler       onmousedownhand = new DHTMLEventHandler(frameDoc);
             onmousedownhand.Handler += new DHTMLEvent(Mouse_Down);
             frameDispDoc.onmousedown = onmousedownhand;
             IHTMLElementCollection col = BrowserExtensions.GetFrames((IHTMLDocument2)frameDoc);
             InspectFrameMouseEvent(col);
         }
     }
 }
Ejemplo n.º 5
0
        public void InjectJavascript(HTMLDocument document)
        {
            string script = "window.guideMe = {userKey:'" + USERKEY + "', trackingId:''};";
            string url    = JSPATH;

            if (document != null)
            {
                mshtml.IHTMLElementCollection headElementCollection = document.getElementsByTagName("head");
                if (headElementCollection != null)
                {
                    mshtml.IHTMLElement injectedScript = document.getElementById("__guideme_script");
                    if (injectedScript == null)
                    {
                        mshtml.IHTMLElement       headElement   = headElementCollection.item(0, 0) as mshtml.IHTMLElement;
                        mshtml.IHTMLElement       guideme       = (mshtml.IHTMLElement)document.createElement("script");
                        mshtml.IHTMLScriptElement guidemeScript = (mshtml.IHTMLScriptElement)guideme;
                        guidemeScript.text = script;

                        mshtml.IHTMLDOMNode guidemeNode = (mshtml.IHTMLDOMNode)guideme;
                        guideme.id = "__guideme_script_config";

                        mshtml.IHTMLElement       element       = (mshtml.IHTMLElement)document.createElement("script");
                        mshtml.IHTMLScriptElement scriptElement = (mshtml.IHTMLScriptElement)element;
                        scriptElement.src = url;

                        element.id = "__guideme_script";
                        mshtml.IHTMLDOMNode node = (mshtml.IHTMLDOMNode)element;
                        mshtml.HTMLBody     body = document.body as mshtml.HTMLBody;
                        body.appendChild(guidemeNode);
                        body.appendChild(node);
                    }

                    Marshal.ReleaseComObject(document);
                }
            }
        }