Пример #1
0
 private void tsmiExecuteJs_Click(object sender, EventArgs e)
 {
     objFrmInputInvokeScript.InitValue         = HtmlCodeFormat.Format(currentElement.OuterHtml);
     objFrmInputInvokeScript.ReturnMethodValue = "";
     objFrmInputInvokeScript.ReturnParamsValue = "";
     objFrmInputInvokeScript.StartPosition     = FormStartPosition.CenterScreen;
     if (objFrmInputInvokeScript.ShowDialog() == DialogResult.OK)
     {
         rtxtTaskScript.Text += "ExcuteJs(" + objFrmInputInvokeScript.ReturnMethodValue + "," + objFrmInputInvokeScript.ReturnParamsValue + ");" + System.Environment.NewLine;
         objFrmInputInvokeScript.Hide();
     }
 }
Пример #2
0
 private void tsmiGetImg_Click(object sender, EventArgs e)
 {
     objFrmInputImgInfo.InitValue         = HtmlCodeFormat.Format(currentElement.OuterHtml);
     objFrmInputImgInfo.ReturnIdNameValue = "";
     objFrmInputImgInfo.ReturnSrcValue    = "";
     objFrmInputImgInfo.ReturnAltValue    = "";
     objFrmInputImgInfo.StartPosition     = FormStartPosition.CenterScreen;
     if (objFrmInputImgInfo.ShowDialog() == DialogResult.OK)
     {
         imgIdName = objFrmInputImgInfo.ReturnIdNameValue;
         imgSrc    = objFrmInputImgInfo.ReturnSrcValue;
         imgAlt    = objFrmInputImgInfo.ReturnAltValue;
         //rtxtTaskScript.Text += "GetImg(" + objFrmInputImgInfo.ReturnIdNameValue + "," + objFrmInputImgInfo.ReturnSrcValue + "," + objFrmInputImgInfo.ReturnAltValue + ");" + System.Environment.NewLine;
         //Image img = WebAutomationHelper.GetRegCodePic(webBrowser1, objFrmInputImgInfo.ReturnIdNameValue, objFrmInputImgInfo.ReturnSrcValue, objFrmInputImgInfo.ReturnAltValue);
         //objFrmShowImage.ImageSource = img;
         //objFrmShowImage.ShowDialog();
         objFrmInputImgInfo.Hide();
     }
 }
Пример #3
0
        void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            // webBrowser1.Document.Encoding = "gb2312";
            // strCache = webBrowser1.DocumentText ;
            tsbSelectElement.Enabled = true;
            //webBrowser1.Document.Click += Document_Click;
            webBrowser1.Document.MouseOver += new HtmlElementEventHandler(Document_MouseOver);
            webBrowser1.Document.MouseMove += new HtmlElementEventHandler(Document_MouseMove);

            //webBrowser1.Document.MouseLeave += new HtmlElementEventHandler(Document_MouseLeave);
            m_hwnd       = webBrowser1.Handle;
            m_hwnd       = WebAPI.GetWindow(m_hwnd, (uint)5); // shell
            m_hwnd       = WebAPI.GetWindow(m_hwnd, (uint)5); // doc obj
            m_hwnd       = WebAPI.GetWindow(m_hwnd, (uint)5); // window
            m_browserPen = new Pen(Color.Red, 2);


            InvokeHelper.Set(rtxtSourceCode, "Text", HtmlCodeFormat.Format(webBrowser1.DocumentText));
        }
Пример #4
0
        void Document_MouseOver(object sender, HtmlElementEventArgs e)
        {
            currentElement = webBrowser1.Document.GetElementFromPoint(e.ClientMousePosition);
            if (canDrawSelected == true)
            {
                Point p       = WebAutomationHelper.GetOffset(currentElement);
                Point pClient = currentElement.OffsetRectangle.Location;
                int   width   = currentElement.OffsetRectangle.Width;
                int   height  = currentElement.OffsetRectangle.Height;
                // 画框
                Graphics g = Graphics.FromHwnd(m_hwnd);
                // g.DrawRectangle(m_browserPen, m_elemRect);
                elemRect = new Rectangle(pClient.X, pClient.Y, width, height);
                g.DrawRectangle(m_browserPen, p.X, p.Y, width, height);
                g.Dispose();
                rtxtConsoleText.Text += (pClient.X + "," + pClient.Y + "," + width + "," + height) + "\n";
                rtxtConsoleText.Select(rtxtSourceCode.TextLength, 0);
                rtxtConsoleText.ScrollToCaret();
            }



            string      path = "";
            HtmlElement elem = webBrowser1.Document.GetElementFromPoint(e.ClientMousePosition);

            path = WebAutomationHelper.GetElementXPath(elem);
            txtElementXPath.Text = path;
            currentElementXPath  = path;
            InvokeHelper.Set(txtElementXPath, "Text", path);

            System.Threading.Thread.Sleep(200);
            //IHTMLDocument2 document = (IHTMLDocument2)webBrowser1.Document.DomDocument;
            //IHTMLControlElement htmlElem = (IHTMLControlElement)document.onmousemove;
            //txtElementCode.Text = IceFormater.ConvertToXml(elem.OuterHtml, true);
            InvokeHelper.Set(txtElementCode, "Text", HtmlCodeFormat.Format(elem.OuterHtml));
        }