Web Browser Control (AxSHDocVw) & sendkeys.. won't work!
Posted on 2005-04-27
What I need to do is to log into a website, and download a file.
In order to do that I need to use this AxSHDocVw control and sendkeys to tab and enter the username / password, click the download link and save it.
(downloading would be a secondary question) For now I need to figure out how to do the sendkeys.
One of 2 things is happening.
1) the page doesn't have focus, so the sendkeys doesn't happen
2) the sendkeys happens before the page is loaded.. (i tried a thread.sleep, even after the navigate method, but somehow this prevents it from loading until the sleeper is over.. see below!)
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf doNavigate), url)
etc etc etc
etc etc etc
I also tried it without the sleeper.
I also tried it using the navigate2complete event.
private sub browser_NavigateComplete2(ByVal sender As Object, ByVal e As browser.DWebBrowserEvents2_NavigateComplete2Event) Handles browser.NavigateComplete2
and put the above code int he method. I'm lost!
nothing seems to work..
I can use:
System.Diagnostics.Process.Start(url) but if i use that I have no way of closing the browser (intelligently) after the sendkeys stuff has done its thing on the web browser (this DOES work, because the sleep function doesn't prevent the browser from loading.)