ActiveDelphi - Índice do Fórum ActiveDelphi
.: O site do programador Delphi! :.
 
 FAQFAQ   PesquisarPesquisar   MembrosMembros   GruposGrupos   RegistrarRegistrar 
 PerfilPerfil   Entrar e ver Mensagens ParticularesEntrar e ver Mensagens Particulares   EntrarEntrar 

Ajuda com código

 
Novo Tópico   Responder Mensagem    ActiveDelphi - Índice do Fórum -> Delphi
Exibir mensagem anterior :: Exibir próxima mensagem  
Autor Mensagem
andersoncamargo1
Novato
Novato


Registrado: Sexta-Feira, 15 de Dezembro de 2017
Mensagens: 10

MensagemEnviada: Qui Abr 26, 2018 11:30 am    Assunto: Ajuda com código Responder com Citação

Eu tenho a seguinte função:

Código:


function GetElementById(const Doc: IDispatch; const Id: string): IDispatch;
// -- Clica em elementos do html
var
  Document: IHTMLDocument2; // IHTMLDocument2 interface of Doc
  Body: IHTMLElement2; // document body element
  Tags: IHTMLElementCollection; // all tags in document body
  Tag: IHTMLElement; // a tag in document body
  I: integer; // loops thru tags in document body
begin
  Result := nil;
  // Check for valid document: require IHTMLDocument2 interface to it
  if not Supports(Doc, IHTMLDocument2, Document) then
    raise Exception.Create('Invalid HTML document');
  // Check for valid body element: require IHTMLElement2 interface to it
  if not Supports(Document.Body, IHTMLElement2, Body) then
    raise Exception.Create('Can''t find <body> element');
  // Get all tags in body element ('*' => any tag name)
  Tags := Body.getElementsByTagName('*'); // Scan through all tags in body
  for I := 0 to Pred(Tags.length) do
  begin // Get reference to a tag
    Tag := Tags.item(I, EmptyParam) as IHTMLElement;
    // Check tag's id and return it if id matches
    if AnsiSameText(Tag.tagName, Id) then
    begin
      Result := Tag;
      Break;
    end
    else
    begin
      if AnsiSameText(Tag.Id, Id) then
      begin
        Result := Tag;
        Break;
      end;
    end;
  end;
end;



Que esta sendo usada da seguinte maneira;

Código:

  Elem := GetElementById(NavegadorPostagem.Document, 'textarea')as IHTMLElement;
  if Assigned(Elem) then
 codigo....



Desta forma eu posso encontrar e clicar, escrever e etc em um textarea ou outra tag, classe, id etc.

Mas como esta consigo clicar em apenas um, o que quero é adaptar o código para que enquanto tiver a tag textarea ele faça o que foi solicitado, consiga pegar todos os textarea que existir... Sei que tem que ser em um laço, mas não sei como adaptar.
Voltar ao Topo
Ver o perfil de Usuários Enviar Mensagem Particular
Mostrar os tópicos anteriores:   
Novo Tópico   Responder Mensagem    ActiveDelphi - Índice do Fórum -> Delphi Todos os horários são GMT - 3 Horas
Página 1 de 1

 
Ir para:  
Enviar Mensagens Novas: Proibido.
Responder Tópicos Proibido
Editar Mensagens: Proibido.
Excluir Mensagens: Proibido.
Votar em Enquetes: Proibido.


Powered by phpBB © 2001, 2005 phpBB Group
Traduzido por: Suporte phpBB