Automated WebBrowser Control in WinForms C# or VB
Using the WebBrowser control, how can i automatically move the mouse to a textbox on the web page, type in so开发者_如何学Cme text, and then submit the form programmatically?
This really isn't possible, at least not without a bunch of ugly hacks.
The primary problem is that you'd need some way to be able to identify the textbox control you wish to type into. That most likely means you need to have designed the HTML form yourself, so that you know what its ID is.
If you have a particular website in mind, and you can assume that it's DOM will stay the same for as long as your application needs to continue working (yeah, right), you can try the hacks suggested here: Automating Facebook Login using WebBrowser Control in C#
But suffice it to say that this smells like a very bad design to me. Automation is tricky to get right as it is, and this particular implementation is trickier than most, considering the dynamic nature of web content.
If you just need open some url, fill form and submit it I would recommend you to use WatiN. It is used for testing, but should do the work.
If you want to post a value from textbox to a page you can use 'HttpWebRequest' as shown here e.g. link
精彩评论