燮pressing保存/打开对话框在WebBrowser控件控件、对话框、pressing、WebBrowser

2023-09-04 04:56:36 作者:人間風月不及你

我有一个WebBrowser控件时自动登录我变成一个网站,并尝试自动下载CSV数据。一切工作正常,但,当它试图下载CSV数据时,弹出一个对话框,询问我是否要保存文件或打开它(就像在IE浏览器)。我所试图做的是自动CSV文件下载到我的选择的文件(或更好,保存CSV文件直接到字符串变量)。我似乎无法弄清楚如何晚饭preSS对话框,并自动捕捉下载。我已经搜索并发现了一些解决方案,但是,他们不适合我,因为:

I have a WebBrowser control that is automatically logging me into a website and attempting to download CSV data automatically. Everything is working fine, except, when it tries to download the CSV data, it is popping up a dialog box, asking if I want to save the file or open it (just like in IE). What I am trying to do is automatically download the CSV file to a file of my choosing (or better, save the CSV file directly into a string variable). I can't seem to figure out how to suppress the dialog box and capture the download automatically. I've search and found a few solutions, however, they don't work for me because:

1)我现在使用的是图形用户界面。所有这一切都是在一类(因此,方法如的SendKeys不会是一个可行的解决方案)做

1) I am now using a GUI. All this is done in a class (therefore, methods such as SendKeys would not be a viable solution)

2)的下载来自一个安全的网站,并要求身份验证。 WebBrowser控件处理所有为我,但如果我使用的WebRequest和WebResponse尝试捕捉下载,我不再验证。

2) The download comes from a secure site and requires authentication. The WebBrowser control handles all that for me, but if I use a WebRequest and WebResponse to try to capture the download, I am no longer authenticated.

我使用C#。任何帮助将是AP preciated。

I am using C#. Any help would be appreciated.

推荐答案

盛强的解决方案是,如果你熟悉C ++的内部最好的。

Sheng Jiang's solutions is the best if you are familiar with the C++ internals.

另外看看在iMacros都为Internet Explorer(=免费浏览器的宏录制插件)是怎么做的。看来他们使用Windows钩子燮preSS IE的下载对话框。

Otherwise have a look how the iMacros for Internet Explorer (= freeware browser macro recorder addon) does it. It seems they use Windows hooks to suppress the IE download dialog.