vb.net monitor an object

Joined
Feb 15, 2002
Messages
1,003
Hey everyone.

I've been playing around a lot with the webbrowser object and the mshtml object library.

I'm having trouble though using webbrowser.readystate. When I click a form object (button) to submit a form the readystate of the browser isn't getting changed to loading. So when I try to do something on the next page that loads I start to run into problems if it hasn't completely loaded.

How can I monitor the webbrowser object while my program is running to tell if it's really busy or not?

Here's some sample code:

Code:
Public Function accept() As Boolean
        timerWait.Enabled = True

        If browserMain.ReadyState = WebBrowserReadyState.Loading Then
            accept()
        ElseIf browserMain.ReadyState = WebBrowserReadyState.Complete Then
            browserMain.Update()
            page = browserMain.Document.DomDocument
            buttonElements = page.getElementsByTagName("input")

            For Each obj As mshtml.IHTMLElement In buttonElements
                If obj.getAttribute("value") = "ACCEPT            " Then
                    obj.click()
                    timerWait.Interval = 500
                    timerWait.Enabled = True
                End If
            Next
        Else
            Return False
        End If
    End Function

    Public Function closeTkt() As Boolean
        timerWait.Enabled = True

        If browserMain.ReadyState = WebBrowserReadyState.Loading Then
            closeTkt()
        ElseIf browserMain.ReadyState = WebBrowserReadyState.Complete Then
            browserMain.Update()
            page = browserMain.Document.DomDocument
            buttonElements = page.getElementsByTagName("input")

            For Each obj As mshtml.IHTMLElement In buttonElements
                If obj.getAttribute("value") = "CLOSE             " Then
                    obj.click()
                    timerWait.Interval = 500
                    timerWait.Enabled = True
                End If
            Next
        Else
            Return False
        End If

    End Function
 
Back
Top