InternetExplorer IE = new InternetExplorer();
string URL;
object o = null;
object misValue = System.Reflection.Missing.Value;
HTMLDocument HTMLDoc = new HTMLDocumentClass();
URL = "http://www.google.com";
//Navigates to site
IE.Navigate(URL,ref o, ref o, ref o,ref o);
//Makes IE visible
IE.Visible = true;
do
//Waits until IE doesn't load page
{
Application.DoEvents();
} while (IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE);
HTMLDoc = (HTMLDocument)IE.Document;
//Locates the element on web document
HTMLInputElement field = (mshtml.HTMLInputElement)HTMLDoc.all.item("q", 1);
try
{
field.value = "1234"; //Sets value of field
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
|