Auto login form with Visual Basic

前端 未结 2 1431
庸人自扰
庸人自扰 2021-01-17 06:50

I need make an auto login form application with Visual Basic 10.0 for the following code:


    

        
2条回答
  •  醉梦人生
    2021-01-17 07:18

    You first need to take all the elements that you want to interact to. If they have an ID, you don't need to search, simply get the element with:

    Dim elem As HtmlElement = Webbrowser1.Document.GetElementById("myId")
    

    If not, you need to search for yours, for example:

    Dim inputs As New List(Of HtmlElement)(a.Document.GetElementsByTagName("input"))
    
    For Each elem As HtmlElement In inputs
        If elem.GetAttribute("name").Equals("uid") Then
            '...
        End If
    Next
    

    To set a value of a input:

    elem.SetAttributte("value", passwordVar)
    

    To click a clickable element (such a submit input):

    elem.InvokeMember("submit")
    

    Or:

    elem.InvokeMember("click")
    

提交回复
热议问题