Drücken Sie die Schaltfläche Speichern von "Datei -Download -Dialog" von Internet Explorer über C#C#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Drücken Sie die Schaltfläche Speichern von "Datei -Download -Dialog" von Internet Explorer über C#

Post by Anonymous »

Ich automatisiere Internet Explorer, um Dateien von einer mit ASP.NET 2.0 erstellten Website herunterzuladen, die Formulare-basierte Authentifizierung verwendet. Um eine vollständige End-to-End-Automatisierung zu erzielen, habe ich die Browserautomatisierung verwendet. Ich versuche jetzt, mit sendkeys () automatisch auf die Taste speichern zu klicken, aber es funktioniert nicht wie erwartet.

Code: Select all

hWnd
) Für den Dialogfeld "Datei herunterladen". Aktion. < /li>
< /ul>

Code: Select all

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetActiveWindow(IntPtr hWnd);

private void Form1_Load(object sender, EventArgs e)
{
IntPtr hwnd = FindWindow(null, "File Download");
if (hwnd != IntPtr.Zero)
{
SetActiveWindow(hwnd);
SendKeys.SendWait("%S");
}
}
Interessanterweise aktivieren Tasten wie Registerkarte, Escape und EINGABE DO. Verwenden Sie denselben Code auf Notepad (durch Ändern des Fenstertitels in findWindow () to "oneunnitled - notepad") gut. Ich verwende IE8.

Code: Select all

IntPtr hwnd = FindWindow(null, "File Download");
IntPtr hokBtn = IntPtr.Zero;
hokBtn = FindWindowEx(hwnd, hokBtn, "Button", IntPtr.Zero);
hokBtn = FindWindowEx(hwnd, hokBtn, "Button", IntPtr.Zero);
uint id = GetDlgCtrlID(hokBtn);
SetActiveWindow(hwnd);
IntPtr res = SendMessage(hokBtn, 0x00F5, 0, IntPtr.Zero); // BM_CLICK
if (res.ToInt32() == 1)
MessageBox.Show("success");
Noch kein Glück.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post