Web browser control and form fields

Posted on 1999-11-03
Medium Priority
Last Modified: 2013-12-25
I would like to be able to access and alter the contents of HTML form fields in the web browser control. I would also like to be able to react to the user clicking on a form field.
It is for a custom IE5 in which the users will not have access to a keyboard. I will hopefully be providing a clickable vb keyboard, activated when a form field is clicked on, and then will copy the keys to the appropriate form field.
I can click on a submit button with VB, but have not found any way of changing the contents of a page or HTML of a page, short of modifying and reloading the whole page - which I don't want to do.
Question by:MikeThelwall
LVL 71

Expert Comment

by:Éric Moreau
ID: 2181257
I don't know much about it but isn't it what DHTML is supposed to do?
LVL 12

Expert Comment

ID: 2181440
I would think that you would have a separate entry field along the top or bottom. You fill it with your virtual keystrokes and then have them click on a VB button [Send]. You then send the string to the server as a CGI script so that VB is doing the work and not the HTML.

You might be able to send a message to the web control every time the user clicks on the virtual keyboard.

Sounds cumbersome in either case.

LVL 13

Expert Comment

ID: 2182573
Have done this in the past but stopped using it because it was to difficult to get 100% correct. Frames were killing the system.
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.


Author Comment

ID: 2182690
Thanks for the comments. I cant do anything to the web pages because this has to work for a set of web pages that I do not have control over - not the whole Internet but a couple of thousand pages on a few different sites.

Mirkwood, I would love to see how you did it. I might be able to live with a system that occasionally crashed if that is the best that is possible.

Expert Comment

ID: 2183208
I want to get this straight ... do you just need to fill information into input boxes on the HTML form?

If that's the case, I'll post some code for you, its really not tough code, just tough to find the docs for how to do it!

Author Comment

ID: 2183733
Yes - I will launch IE5 through the web browser control and allow the user to browse (a section of) the Internet at will by clicking on links. When they want to fill in a form I need to be able to intercept the click on the form and launch a clickable VB keyboard so they can enter information with this. I need to be able to copy the keys they type with the keyboard into the form field.

So I need to intercept a click on a form and fill in information directly into the boxes.

Accepted Solution

vettranger earned 400 total points
ID: 2183810
The following code is a sample that will find and fill in inputboxes on an HTML page.

I'm guessing you're not having any trouble capturing the input from your keyboard substitute and building the strings. So there's your string to put in the inputbox.

However, I've no idea how to determine if a particular inputbox has the focus in the browser.

Private Sub FillHTMLInputBoxes(HTMLDoc As HTMLDocument)
    On Error GoTo handleError
    If HTMLDoc Is Nothing Then
        ' Not an HTLM document
        Exit Sub
    End If
    Dim BODYElement As IHTMLElement
    Set BODYElement = HTMLDoc.body
    If BODYElement.tagName = "BODY" Then
        Dim ELEMENTCo As IHTMLElementCollection
        Set ELEMENTCo = HTMLDoc.All
        Dim Element As HTMLAnchorElement
        For Each Element In ELEMENTCo
            If Element.tagName = "INPUT" Then
                b = Element.outerHTML
'                If InStr(b, "userid") And ReviewClicked = False Then
                If InStr(b, "userid") Then
                   Element.innerText = MyUserID
                End If
                If InStr(b, "pass") Then
                   Element.innerText = MyPassword
                End If
            End If
    End If

    Exit Sub

        MsgBox (Err.Description)

End Sub

Author Comment

ID: 2185547
Brilliant, thanks!!!. - I'd tried outerHTML but it seemed  to  be read only. I didn't think of trying innerHTML in this way.

Expert Comment

ID: 2186185
It took me a lot of trial and error to get it myself! LOL

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question