none
Yahoo Logout

    Question

  • How can i perform perform  Logout action using this Function

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted



    Saturday, December 19, 2009 5:37 PM

Answers

All replies

  •     Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            WebBrowser1.Document.InvokeScript("_CD", New Object() {"exit"})
        End Sub

    Tested with Yahoo mail, should work with all Yahoo! sites.



    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game
    Saturday, December 19, 2009 6:08 PM
  •     Private
     Sub
     WebBrowser1_DocumentCompleted(ByVal
     sender As
     Object
    , ByVal
     e As
     System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles
     WebBrowser1.DocumentCompleted
            WebBrowser1.Document.InvokeScript("_CD"
    , New
     Object
    () {"exit"
    })
        End
     Sub
    
    

    Tested with Yahoo mail, should work with all Yahoo! sites.



    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game


    Thanks for you reply :) I use your code but its not working :(

    My code

     Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
            For Each curElement As HtmlElement In theElementCollection
                Dim controlName As String = curElement.GetAttribute("id").ToString
                If controlName = "username" Then
                    curElement.SetAttribute("Value", "email")
                End If
            Next

    theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
            For Each curElement As HtmlElement In theElementCollection
                Dim controlName As String = curElement.GetAttribute("id").ToString
                If controlName = "passwd" Then
                    curElement.SetAttribute("Value", "password")
                End If
            Next

    theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
            For Each curElement As HtmlElement In theElementCollection
                If curElement.GetAttribute("value").Equals("Sign In") Then
                    curElement.InvokeMember("click")
                  End If
            Next

     WebBrowser1.Document.InvokeScript("_CD", New Object() {"exit"})

    After Login its not perform Logout action...
    Saturday, December 19, 2009 6:27 PM
  • After you login where you invoke the click member you probably need to give it time to process that action.  Here's a sub that I've used on some hobby projects, it's got some extra junk in it.  It could end up endless looping which is why I call the Application.DoEvents to keep the UI responsive, also, I have a private variable where when the stop button is clicked, it sets the variable to true so I can let the user stop the waiting:

        ''' <summary>
        ''' Wait for the web browser to respond.
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub WaitForBrowserResponse()
    
            Try
                While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
    
                    If _stopScripts = True Then
                        Call SetStatus("Scripts Stopped")
                        Exit Sub
                    End If
    
                    Call SetStatus("The web browser is processing... please wait...")
                    Application.DoEvents()
                End While
    
                While WebBrowser1.IsBusy
    
                    If _stopScripts = True Then
                        Call SetStatus("Scripts Stopped")
                        Exit Sub
                    End If
    
                    Application.DoEvents()
                End While
            Catch ex As Exception
                ' eat error
                Call LogWindow(ex)
            End Try
    
        End Sub


    Saturday, December 19, 2009 7:01 PM
  • After you login where you invoke the click member you probably need to give it time to process that action.  Here's a sub that I've used on some hobby projects, it's got some extra junk in it.  It could end up endless looping which is why I call the Application.DoEvents to keep the UI responsive, also, I have a private variable where when the stop button is clicked, it sets the variable to true so I can let the user stop the waiting:

        ''' <summary>
    
        ''' Wait for the web browser to respond.
    
        ''' </summary>
    
        ''' <remarks></remarks>
    
        Public
     Sub
     WaitForBrowserResponse()
    
            Try
    
                While
     WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
    
                    If
     _stopScripts = True
     Then
    
                        Call
     SetStatus("Scripts Stopped"
    )
                        Exit
     Sub
    
                    End
     If
    
    
                    Call
     SetStatus("The web browser is processing... please wait..."
    )
                    Application.DoEvents()
                End
     While
    
    
                While
     WebBrowser1.IsBusy
    
                    If
     _stopScripts = True
     Then
    
                        Call
     SetStatus("Scripts Stopped"
    )
                        Exit
     Sub
    
                    End
     If
    
    
                    Application.DoEvents()
                End
     While
    
            Catch
     ex As
     Exception
                ' eat error
    
                Call
     LogWindow(ex)
            End
     Try
    
    
        End
     Sub
    
    



    I got your point :) .i will try your code but is this possible my application wait until progress-bar=100.
    and after 100% done ,then  its perform logout action?

    I use progress-bar with my browser.

    My progress bar code is

    Private Sub ToolStripProgressBar1_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged, ToolStripProgressBar1.Click
            Dim p, d, t As Integer
            d = e.CurrentProgress
            t = e.MaximumProgress
            If t < 1 Then t = 1
            p = Int(d / t) * 100
            If p > 100 Or p < 0 Then Exit Sub
            ToolStripProgressBar1.Value = p

        End Sub



    Saturday, December 19, 2009 7:34 PM