Hello,
In general, what you need to do here is grab the appropriate window handles and then send the proper message (like click) to the appropriate button. A windows form and all of the components on the form are considered windows. Each window has a handle and once you get that handle you can use it to interact with that window.
You can determine which window is the appropriate window by looking at its title bar text and its class (for example dialog windows are of class #32770). You can get a lot of information about the windows opening and closing on your computer by using the spy++ utility. When you install visual studio, Spy++ is accessible from the from the Visual Studio Tools under the start menu. This tool will list the window class numbers, title bar text, and the parent window. This information is useful for programmatically finding the appropriate for and then the appropriate control to interact with on that form (they are considered windows).
After you have that information, you can use the following User32.dll API functions to get the window handle for the button that you would like to click and then send the click message to the button. Here is an example using the older AxWebBrowser control, but the windows interaction is the same. This example programmatically populates and html file upload dialog box (via the file browser modal window) and submits it.
Also, here is a link to the needed functions on MSDN:
http://msdn.microsoft.com/
Main Topics
Browse All Topics





by: TheLearnedOnePosted on 2009-08-18 at 06:14:20ID: 25122805
I believe that what you need to do with the System.Windows.Forms.WebBr owser control is to handle the Navigating event, set e.Cancel = True, and handle the file downloading yourself, instead of letting the WebBrowser control do that. You should be able to get the URL from the e.Url.ToString() value.