I'm trying to get a VB.Net application to type into a file upload control field. The application currently navigates to the correct page, and clicks the "BROWSE" button so the "Choose File" window opens, but when I use SendKeys.Send( "Testing" ), nothing types into the field, even though the cursor is in that field. Is there something special I need to do to get text into that field? I need to type a value into the field and click the "Open" button to return back to the upload control field. As an FYI, IE8 won't allow typing directly into these "file" type fields anymore, so I have to find a workaround so users don't have to do this all the time to upload files.

My Code looks like this:

Public Shared Function GetWindows() As Dictionary(Of String, String)        Dim list As New Dictionary(Of String, String)        For Each window As InternetExplorer In New ShellWindows()            ' Skip Windows Explorer instances, since the Document type is IShellFolderViewDual2.             If TypeOf window.Document Is mshtml.HTMLDocument Then                Dim HTMLDoc As mshtml.HTMLDocument                HTMLDoc = window.Document                 Dim wbr1 = HTMLDoc.getElementById("upload1")                Dim strId As String                If Not (wbr1 Is Nothing) Then                    strId = wbr1.id                    wbr1.click()                    SendKeys.Send("ABCD")                    SendKeys.Send("Testing123")                End If            End If        Next window        Return list    End Function    Public Shared Function GetWindows() As Dictionary(Of String, String)
        Dim list As New Dictionary(Of String, String)
        For Each window As InternetExplorer In New ShellWindows()
            ' Skip Windows Explorer instances, since the Document type is IShellFolderViewDual2. 
            If TypeOf window.Document Is mshtml.HTMLDocument Then
                Dim HTMLDoc As mshtml.HTMLDocument
                HTMLDoc = window.Document

                Dim wbr1 = HTMLDoc.getElementById("upload1")
                Dim strId As String
                If Not (wbr1 Is Nothing) Then
                    strId = wbr1.id
                    wbr1.click()
                    SendKeys.Send("ABCD")
                    SendKeys.Send("Testing123")
                End If
            End If
        Next window
        Return list
    End Function

Please let me know if you need more information. Thank you for your help.

-TIM

I'm not really sure you're going to be able to use SendKeys into that dialog. I think that the Windows File/Save dialogs are going to be in unmanaged code. You'd have to get the HWND ID for the window, and then do something (I'm not sure what) to put the keys in that you want. I'm not really up on Win32 UI programming, but I thought I'd at least try and point you in some direction...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.