Ok right now I have to configure routers manually by inserting the exact same data into a router's configuration panel (website on router) then swap out the configured router with one that needs the exact same setup and redo this process over and over. I would like to write an application that fills in all the needed boxes,selects values from drop down menu's and fills in any other information and presses the save & restart button for me is this possible I initially though about trying to find the file on the router that its writing to thinking making its one config file maybe if thats the case I could just write to the file but im not entirely sure.

input data to website
R.Tutus
it's a tricky one really since you need to know what the page has in terms of elements and its names etc...
http://msdn2.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx
http://msdn2.microsoft.com/en-us/library/system.windows.forms.htmldocument.getelementbyid.aspx
http://msdn2.microsoft.com/en-us/library/system.windows.forms.htmldocument.getelementbyid(VS.80).aspx
once you get hold of an element, just set its innerText property then submit it or whatever so it can go ahead and process it.
Example, I wanted to look for an element called "txtSearch" in the current document.
HtmlElement theElement = this.theWebBrowserControl.Document.GetElementById("txtSearch");
if (theElement != null)
{
theElement.InnerText = "hi!"; //sets the text inside this control
}
keithpsft
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
HtmlElement es = webBrowser1.Document.GetElementById("hostName");
// foreach (HtmlElement ele in es)
// {
if (es != null)// && es.Count != 0)
{
mystring = es.InnerText;
textBox1.Text = mystring;
// IsIPAddress(mystring.Trim());
}
else
{
errorProvider1.SetError(textBox1, "No Data");
}
// }
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://192.168.1.1");
}
}
}
Noremac
cues7a
HtmlElement PhraseInput = webBrowser1.Document.GetElementById("phrase");
HtmlElementCollection theElements = this.webBrowser1.Document.GetElementsByTagName("input");
if (PhraseInput != null)
{
PhraseInput.InnerText = "test phrase";
}
foreach (HtmlElement curElement in theElements)
{
if (curElement.GetAttribute("Value").Equals("submit"))
{
curElement.InvokeMember("click");
}
}
still inputs the phrase ok but it doesn't press the button and as far as retrieving the info on the next page..you lost me :P
dkonline
Lechal
I can now edit the input boxes my question is:
once I have added my text to the input box how do I press a submit button and retrieve info from the next page that loads. To give you an idea
http://www.powerdog.com/wepkey.cgi
That website what I am doing is using this program to input a phrase into the input box and I would like it to press submit and then retrieve the first key from the list on the following page.
yhong
Mobile_Mike
you wont be able to write to the file. its highly protected and encrypted. You could use a webbrowser control, if the router is web configurable, then kind of automate the process on the documentcompleted event of the webbrowser control and set the inputs/dropdown boxes via the aid of GetElementById using the Document property of the control. Would this get you started
otherway is to manually do it in that, you can automatically launch an IE instance, navigate to the page you want, then control your mouse and keyboard and send keys to IE however this wouldnt be better, the first option would as everything you pretty much need is there and doesnt require you to not use your PC at the same time
Muhsin Zahid Uğur
no worries. hehe, funny, I was just replying to someone with the same thing about invoking the button. I'm not sure how this will work with perl script, being the same or not but...lets give a try.
HtmlElementCollection theElements = this.webBrowser1.Document.GetElementsByTagName("input"); 'get an input element
foreach (HtmlElement curElement in theElements)
{
if (curElement.GetAttribute("Value").Equals("submit")) 'get the value of the current element. is it a submit type if so...
{
curElement.InvokeMember("click"); 'invoke the click event!
}
}
in regards to retrieving the next page, well, in the documentcompleted event, as you have, this will be fired when the document has finished loading. So to be safe, I would suggest:
Once checking the current page url, then execute the operations you want to execute on that method
now, in regards to retrieving the data on the page, you need to either go through the elements as you currently are doing, or look for the innertext/outertext for the elements and see what the responses are/values are.
innertext contains the text in that control, as well as the ability to set it
kgaudana123
yoshikatsu
hmm. I'm not sure what you are trying to do in regards to where you are going to be configuring it, meaning if you are going to be taking values out from the element into your own textbox or if you are going to be modifying the values in that same textbox on the webpage.
if its on the webpage then you almost have it....
HtmlElement es = webBrowser1.Document.GetElementById("hostName");
if (es != null)
{
es.InnerText = "new value";
}
else
{
errorProvider1.SetError(textBox1, "No Data");
}
but yes your generally along the right lines
elvis8900
Alexander Stoyan
Gary Spence