🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #414

Find and click a link with CppWebBrowser

#414
From: Eduardo Jauch
Date: Thu, 01 Feb 2007 18:15
59 lines
2408 bytes
I loaded a page in my program using TCppWebBrowser, that cointais these 
lines (among many others):

<a href="javascript: confirmarInformacoesDeVisto();">
<img src="bt_voltar.gif" border="0"></a>&nbsp;

<a href="javascript: confirmarAgendamento();">
<img src="bt_confirmar.gif" border="0"></a>&nbsp;

<a href="javascript: listaSituacaoAgendamento();">
<img src="bt_cancelar.gif" border="0"></a>


How can I execute by program the second line?
I mean, how can I "simulate" by my program the click of the mouse in the 
specified link by a user?

I saw a code on another post that execute a "click" on a button (by Remy).

#include <mshtml.h>
#include <utilcls.h>

if( CppWebBrowser1->Document )
{
   TComInterface<IHTMLDocument2> Doc;
   CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2, 
(LPVOID*)&Doc);

   if( Doc )
   {
     TComInterface<IHTMLElementCollection> All;
     Doc->get_all(&All);

     if( All )
     {
       TComInterface<IDispatch> Disp;
       All->item(TVariant(WideString("secure_exit")),
TVariant(0), &Disp);

       if( Disp )
       {
         TComInterface<IHTMLElement> Element;
         Disp->QueryInterface(IID_IHTMLElement,
(LPVOID*)&Element);

         if( Element )
	  Element->click();
       }
     }
   }
}

But in this example, the "button" has a name,

<input TYPE="button" NAME="secure_exit" VALUE=" Finished "
onClick="logout();">

And my "links" don't have...
So, how to FIND the right link in the page and how to execute it?
Technical Details
Message-ID: <45c22e07@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,d14e4843c29e91dd,start
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 01 Feb 2007 16:15:33 -0200
From: Eduardo Jauch <eduardo.jauch@gmail.com>
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.web
Subject: Find and click a link with CppWebBrowser
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 200.193.161.111
Message-ID: <45c22e07@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1170353671 200.193.161.111 (1 Feb 2007 10:14:31 -0800)
Lines: 59
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail