Not really an answer, but it may turn into an answer later. Are use sure the focus is inside the IE "Choose File to Upload" dialog, when you do SendKeys
? Use the following to verify that, put the code from below Task.Delay(4000)
into your ContinueWith
and check the output from Debug.Print
.
static class Win32
{
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
}
private async void Form1_Load(object sender, EventArgs ev)
{
await Task.Delay(4000);
var currentWindow = new System.Text.StringBuilder(1024);
Win32.GetWindowText(Win32.GetForegroundWindow(), currentWindow, currentWindow.Capacity);
Debug.Print("Currently focused window: \"{0}\"", currentWindow);
}