I have a simple C# WinForms Crud AP for employees that have to do a lot of simple web lookups. Currently it loads 5 websites and puts a search term into the clipboard. The employee then has to paste the search term into the search textbox on each of the sites and hit enter. Is there a simple way to enter the data for them? The search textbox usually has focus when the sites load, I just cannot find a way to detect when the page has loaded or how to send the data to the window.
It looks, from these helpful answers, like I was going about this the wrong way. I was using code found with the help of my good friend, Mr. Google
System.Diagnostics.Process.Start("www.website.com");
Clipboard.SetText(textBox1.Text, TextDataFormat.Text);
I will do some more research this week on the webbrowser control
You can use WebBrowser’s DocumentCompleted event to be notified when the page has finished loading.
If the textbox you’re entering your text into has a unique id, you can use WebBrowser.Document.GetElementById:
GetElementById returns an instance of HtmlElement (or null, if the element wasn’t found). Note that “.InnerText” might not work for all element types, there’s also InnerHtml and lots of other properties, I’d recommend playing around with the HtmlElement class before deciding how to use it.
Let me know if you don’t have a unique id for the element, there’s lots of otherways to find an element. including using the exposed DOM via Document.Body.