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;

  • 相关阅读:
    1.Hello World
    1.Hello World
    1.Hello World
    32.IDEA新建MAVEN项目时速度缓慢
    31.最特殊的快捷键 Alt + Enter 介绍(新用户必看)
    HelloWorld
    mybatis要指定参数再数据库中的类型,类型要全大写
    递归函数,修改全局变量,高阶函数
    不定长参数
    函数返回值return,列表字典的拆包
  • 原文地址:https://www.cnblogs.com/honeynm/p/4436022.html
Copyright © 2011-2022 走看看