Hi, i've been looking around for help with this problem but google seems to just send a load of crap my way so its finally got to the point where i'm asking specifically for help. Here is the code;
void CWebRobotDlg::OnBnClickedDologin()
{
void* pElem= ElemFromID(L"username", IID_IHTMLInputElement) ;
IHTMLInputElement* pTextBoxUser= (IHTMLInputElement*)pElem;
bstr_t sUser(L"UsErNaMe"); // <<<-- your login name here
pTextBoxUser->put_value(sUser); // populate the text box!
//--------------------------------------------------------
pElem= ElemFromID(L"password", IID_IHTMLInputElement) ;
IHTMLInputElement* pTextBoxPswd= (IHTMLInputElement*)pElem;
bstr_t sPswd(L"PaSsWoRd"); // <<<-- your login password here
HRESULT hr= pTextBoxPswd->put_value(sPswd); // populate the text box!
//--------------------------------------------From here is where the problem starts.
pElem= ElemFromID(L"checkbox", IID_IHTMLInputElement) ;
IHTMLInputElement* pCheckBoxChkbx= (IHTMLInputElement*)pElem;
bstr_t sChkbx(L"VALUE"); // <<<-- ??
pCheckBoxChkbx->put_value(sChkbx); // Not working
//-------------------------------------------End Of problem area.
pElem= ElemFromID(L"submit", IID_IHTMLElement);
IHTMLElement* pSubmit= (IHTMLElement*)pElem;
hr= pSubmit->click(); // GO!
}
As you can see this code is filling in a form on a website (completely anonymised atm). It works perfectly but there is an optional checkbox that I would like to tick before the form is submitted. I have harvested the correct id's/names from the website source and can put a value into text box fields, but im using borrowed code and I cant work out how to interact with the input type of check boxes.
IHTMLInputElement* pTextBoxPswd= (IHTMLInputElement*)pElem;
I Assumed the "TextBox" part of this line was defined in mshtml.h, I also assumed it was specifically designed to interact with text box type web elements and not check boxes, so I tried "Checkbox". This was my best guess. I'm also unser what value to pass to the box once i've got the element name correct.
Thanks in advance, Alochai.