🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
3 messages
3 total messages Started by BruBru Sat, 27 May 2006 15:22
Fill in IE forms
#625
Author: BruBru
Date: Sat, 27 May 2006 15:22
25 lines
1764 bytes
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,
Re: Fill in IE forms
#626
Author: Hans Galema
Date: Sat, 27 May 2006 15:26
13 lines
1221 bytes
BruBru wrote:

> 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.
Re: Fill in IE forms
#627
Author: Gizmo
Date: Sat, 27 May 2006 19:50
131 lines
5501 bytes
"BruBru" <bruno_scheirsen@hotmail.com> wrote:
>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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads