zoukankan      html  css  js  c++  java
  • C#客户端填充外部IE浏览器中网页文本(input)且不提交

    //引用COM组件
    //Microsoft HTML Object Library
    //Microsoft Internet Controls

     记得改成x86

                SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
                string filename;
                foreach (SHDocVw.InternetExplorer ie in shellWindows)
                {
                    filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
                    if (filename.Equals("iexplore"))
                    {
                        SetText(string.Format("Web Site  : {0}", ie.LocationURL));
                        mshtml.IHTMLDocument2 htmlDoc = ie.Document as mshtml.IHTMLDocument2;
                        SetText(string.Format("  Document Snippet: {0}",
                        ((htmlDoc != null) ? htmlDoc.body.outerHTML
                        : "***Failed***")));
                        SetText(string.Format("{0}{0}", Environment.NewLine)); 
    
                        mshtml.HTMLInputElementClass input;
                        foreach (mshtml.IHTMLElement ieElement in htmlDoc.all)
                        {
                            if (ieElement.tagName.ToUpper().Equals("INPUT"))
                            {
                                input = ((mshtml.HTMLInputElementClass)ieElement); 
    
                                if (input.name == "gmfmc")
                                {
                                    input.value = "****";
                                }
                                else if (input.name == "gmfnsrsbh")
                                {
                                    input.value = "12300000747150428A";
                                }
                                else if (input.name == "gmfdz")
                                {
                                    input.value = "北京市";
                                }
                                else if (input.name == "gmfdz")
                                {
                                    input.value = "010-512011";
                                }
                                else if (input.name == "gmfkhh")
                                {
                                    input.value = "北京银行";
                                }
                                else if (input.name == "gmfyhzh")
                                {
                                    input.value = "132465798798";
                                }
                                else if (input.name == "gmfsjhm")
                                {
                                    input.value = "18456487920";
                                }
                                else if (input.name == "gmfyxdz")
                                {
                                    input.value = "sa@123.com";
                                }
                            }
                        }
                    } 
                }
    

      

  • 相关阅读:
    TransmitFile
    xml
    鼠标划过表格行变色-简洁实现
    关于表变量
    显式接口成员实现
    华为致新员工书
    C#实现的堆栈
    Gridview中合并单元格,某字段的内容相同时如何只显示一个,屏蔽相同列或行的内容(转)
    ASP.NET 验证控件
    动态SQL EXEC
  • 原文地址:https://www.cnblogs.com/dyfisgod/p/8600950.html
Copyright © 2011-2022 走看看