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;

  • 相关阅读:
    第二次结对编程作业
    团队项目-需求分析报告
    Beta阶段第四次会议
    Beta阶段第三次会议
    Beta阶段第二次会议
    Beta阶段第一次会议
    Beta设计和计划
    项目展示
    事后分析
    α版本发布说明
  • 原文地址:https://www.cnblogs.com/honeynm/p/4436022.html
Copyright © 2011-2022 走看看