Results 1 to 3 of 3

Thread: Simulating Click on a Web Page

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Simulating Click on a Web Page

    Hi.

    I'm trying to simulate a click on a web page using Visual C++. I'm able to extract the contents of the page and get all the elements, but I can't get the click to work when the command (push) button on the web page can have a couple of values. Here's a snippet of my code:
    Code:
    // Set the name and index of the
    // command button on the web page.
    varID.SetString("DoThis");
    varIdx.intVal = 0;
    
    // Get all elements on the web page.
    pNewDoc->get_all(&pElemColl);
    
    hr = pElemColl->item(varID, varIdx, &pElemDisp);
    
    if(SUCCEEDED(hr))
    {
    	hr = pElemDisp->QueryInterface(IID_IHTMLElement, (void**)&pElem);
    
    	if(SUCCEEDED(hr))
    	{
    		// Obtained element with ID of "DoThis".
    		// Here is where I need to assign a Value to DoThis
    		// If it helps, in VB, the syntax is just DoThis.Value = 'GetName'
    		// After the value is assigned, I want to click the DoThis element.
    		pElem->click();
    		pElem->Release();
    	}
    }
    I'm sure this is probably simple, put I need some help with it.

    Thanks in advance.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I think
    pElem->set_Value(arg);
    should work. arg would either be a BSTR or a VARIANT, you need to look that up in the header files, don't ask me which.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Thumbs up Corned Bee ...

    Thanks. I was able to get it to work!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width