BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fill in IE forms

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Web)
View previous topic :: View next topic  
Author Message
BruBru
Guest





PostPosted: Sat May 27, 2006 8:22 pm    Post subject: Fill in IE forms Reply with quote



Hello all,

Could anyone tell me how it is possible to fill in some fields in a web-form
(.htm) interacting with the web browser (IE 6). The purpose of it, is to be
able to fill in the formfields with data from interbase tables and the
submit the form. If i can't automate this, i'll have to keep retyping data
displayed by my interbase-app, into the web-browser fields. (would save me
lots of stupid work)

piece of the html -source of the page:

<form method="post" action="/dimona/private/ingave/wizard.htm">
<INPUT type='hidden' name='_ticket_to_process' value='2'/>
<table border="0">
<tr>
<td class="stLabelBold" >Familienaam</td>
<td>
<input type="text" name="contract.werknemer.familieNaam"
styleClass="textBox" value="">
</td>
</tr>

Still programming with borland C++ Builder 4 Prof.

Thx in advance,
Back to top
Hans Galema
Guest





PostPosted: Sat May 27, 2006 8:26 pm    Post subject: Re: Fill in IE forms Reply with quote



BruBru wrote:

Quote:
Still programming with borland C++ Builder 4 Prof.

Is TCppWebBrowser on the Internet Palette?

With that component you can do it.

It has been demonstrated sometimes already in this group.

You can try to google for it first.

Hans.
Back to top
Gizmo
Guest





PostPosted: Sun May 28, 2006 12:50 am    Post subject: Re: Fill in IE forms Reply with quote



"BruBru" <bruno_scheirsen (AT) hotmail (DOT) com> wrote:
Quote:
Hello all,

Could anyone tell me how it is possible to fill in some fields in a web-form
(.htm) interacting with the web browser (IE 6).
for sample...

first cut:
//on target page
....
WideString wsName = "Name";
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc;
CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pColl;
CComQIPtr<IDispatch, &IID_IDispatch> pTmpDisp;
CComQIPtr<IHTMLInputElement, &IID_IHTMLInputElement> pElement1;
CComQIPtr<IDispatch, &IID_IDispatch> pDisp1;
CComQIPtr<IHTMLInputElement, &IID_IHTMLInputElement> pElement2;
CComQIPtr<IDispatch, &IID_IDispatch> pDisp2;

if ( SUCCEEDED (WB->Document->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pDoc)))
{
if ( SUCCEEDED (pDoc->get_all(&pColl)))
{
if ( SUCCEEDED (pColl->tags(TVariant("INPUT"), &pTmpDisp)))
{
pColl=pTmpDisp;
TVariant v1("string"), v12("Only"), v2;
pColl->item( v1, v2, &pDisp1);
pElement1 = pDisp1;
pElement1->put_value(wsName);

pColl->item( v12, v2, &pDisp2);
pElement2 = pDisp2;
pElement2->put_checked(1);

// нажать на кнопку //click SUBMIT Button
IHTMLElementCollection *HTMLForms = NULL;

if ( SUCCEEDED ( pDoc->get_forms ( &HTMLForms ) ) && HTMLForms )
{
// slHtmlFormName <form name=...>
TVariant vName5(0);
TVariant vIndex5;
IDispatch *pDisp5 = NULL;

if ( SUCCEEDED ( HTMLForms->item (vName5, vIndex5, &pDisp5 ) ) && pDisp5 )
{
IHTMLFormElement *HTMLForm = NULL;

if ( SUCCEEDED ( pDisp5 -> QueryInterface ( IID_IHTMLFormElement, ( LPVOID* )&HTMLForm ) ) && HTMLForm )
{
HTMLForm -> submit ();
HTMLForm -> Release ();
}

pDisp5 -> Release ();
}

HTMLForms -> Release ();
}
}
}
}

second cut:
void __fastcall TMyIEExtentionImpl::WIGetStat(String user)
{
//TODO: Add your source code here
//iieo?aiea noaoenoeee ?a?ac WinInet
//http://ps.company.net/cgi-bin/status.pls
// for POST
// char *pTarget = "/cgi-bin/status.pls";
// char *pOptHeaders = "user=gizmo";

// for GET
//char *pTarget = "/cgi-bin/status.pls?user=gizmo";
//char *pOptHeaders = NULL;

String Line, Msg;

HINTERNET hInternet = InternetOpen("AGENT 007",
INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);

HINTERNET hConnection = InternetConnect(hInternet, "ps.company.net",
80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);

HINTERNET hRequest = HttpOpenRequest(hConnection , "POST",
"/cgi-bin/status.pls",
NULL, NULL, NULL,
INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE, NULL);

if(TRUE == ::HttpSendRequest( hRequest,
NULL,
0,
user.c_str(),
user.Length()))
{
//... You this not it is necessary ...
DWORD dwRead;
TCHAR szTemp[1024];
while (InternetReadFile(hRequest, (LPVOID)szTemp, 1023, &dwRead))
{
if (!dwRead) break;
szTemp[dwRead]='\0';

Line = Line + String(szTemp);
}
}
// close resource
InternetCloseHandle(hRequest);
InternetCloseHandle(hConnection);
InternetCloseHandle(hInternet);
// ... is it here found only for example ...
int startpos = Line.Pos ( "<strong>" ) + AnsiString("<strong>").Length();
int endpos = Line.Pos ( "</strong>" );
// ... oi?ie?oai niiauaiea ...
Line = Line.SubString ( startpos, endpos-startpos );
Msg.printf("Iauai iieo?aiiie eioi?iaoee:\n\r%s aaeo", Line.c_str());
// ... iieo?aai HWND Browser-a ...
HWND hBrowser=NULL;
long lBrowser;
if ( SUCCEEDED (m_pWebBrowser2->get_HWND(&lBrowser)))
hBrowser=(HWND)lBrowser;

MessageBox(hBrowser, Msg.c_str(), "Noaoenoeea gizmo", MB_OK);
}
....
WIGetStat(sPostData);

third:
http://bdn.borland.com/article/0,1410,27519,00.html
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Web) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.