zoukankan      html  css  js  c++  java
  • 自动填写IE的网页的输入框的内容

    procedure TForm1.PutData;

    var

        ShellWindow: IShellWindows;

        nCount: integer;

        spDisp: IDispatch;

        i,j,X: integer;

        vi: OleVariant;

        IE1: IWebBrowser2;

        IDoc1: IHTMLDocument2;

        iELC : IHTMLElementCollection ;

        S,S2 : string;

        HtmlInputEle : IHTMLInputElement;

        HtmlSelEle : IHTMLSelectElement;

    begin

        ShellWindow := CoShellWindows.Create;

        nCount := ShellWindow.Count;

        for i := 0 to nCount - 1 do

        begin

            vi := i;

            spDisp := ShellWindow.Item(vi);

            if spDisp = nil then continue;

            spDisp.QueryInterface( iWebBrowser2, IE1 );

            if IE1 <> nil then

            begin

                IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);

                if iDoc1 <> nil then

                begin

                      ielc:=idoc1.Get_all;

                      for j:=0 to ielc.length-1 do

                      begin

                          Application.ProcessMessages;

                          spDisp := ielc.item(J, 0);

                              if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))then

                              with HtmlInputEle do

                              begin

                                  S2:=Type_;

                                  S2:=UpperCase(S2);

                                  //我把所有的input都填上 try , checkbox 都打勾

                                  if (StrComp(PChar(S2),'TEXT')=0) or (StrComp(PChar(S2),'PASSWORD')=0) then

                                     value :='try' //S:=S+#9+Value

                                  else if StrComp(PChar(S2),'CHECKBOX')=0 then

                                  begin

                                    checked := True;

                                  end;

                              end;

                              if SUCCEEDED(spDisp.QueryInterface(IHTMLselectelement ,HtmlSelEle))then

                              with HtmlSelEle, Memo1.Lines do

                              begin

                                 S:=S+#9+IntToStr(selectedIndex+1); //这个是获取数据了

                              end;

                      end; //END FOR

                      Memo2.Lines.Add(S);

                      exit;

                end;

            end;

        end;

    end;

  • 相关阅读:
    ERROR: HHH000123: IllegalArgumentException in class: com.tt.hibernate.helloworld.News, setter method of property: date
    Tomcat服务器重启失败:The server may already be running in another process, or a system process may be using the port.
    ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 7
    跨平台开发之阿里Weex框架环境搭建(一)
    fielderror里的fieldName代表的是jsp里的fieldName还是Action类的成员变量?(待解答)
    Virtualbox 安装
    下载CentOS镜像
    Express框架的创建
    安装MongoDB及所遇见的问题和解决方案
    javascript 插入DOM节点
  • 原文地址:https://www.cnblogs.com/honeynm/p/4436022.html
Copyright © 2011-2022 走看看