Reputation: 6921
My application has to automate form filling and upload files using a webBrowser control. When I invokeMember("click"), the usual "Choose file to upload" form pops up and comes in front of any other application I may be using at the same time. Is there a way to intercept this window so that I can leep my form filling and file uploading in the background ?
Upvotes: 1
Views: 6398
Reputation: 2398
Due to security reasons, IE does not allow programmatically setting a file to upload. (In fact, you can't even use SendKeys, as Microsoft closed that hole too.)
However, you can accomplish what you are looking to do by adding the file to the HTTP header easily. There is a great tutorial that will help you do so:
http://www.codeproject.com/KB/aspnet/set-webbrowser-file-input.aspx
Upvotes: 0
Reputation: 111
The answer is that you probably can, however it will likely be an absurdly complicated process. You can hook into the windows CALLWNDPROCRET notification chain which can allow you to get to events (like dialog creation) before they are processed by the webbrowser control. I've used this before to do things like suppress the 'untrusted certificate' warning dialog, however I wouldn't recommend going down this route unless you have absolutely no other choice.
Upvotes: 2