-2

我需要使用 Visual Basic 10.0 为以下代码制作一个自动登录表单应用程序:

</script>
    <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
        <table cellpadding="0" cellspacing="0" border="0" height="100%">
            <tr>
                <td rowspan="10" width="50%" height="100%" background="images/bg1222.jpg" style="background-position:right top; background-repeat:repeat-y"></td>
                <td rowspan="10" width="1" bgcolor="#000000"></td>
                <td valign="top">
                    <table cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td width=100%>
                                <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="778" height="153">
                                    <param name="movie" value="images/hed2.swf">
                                    <param name="quality" value="high">
                                    <embed src="images/hed2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="778" height="153"></embed>
                                </object>
                            </td>
                        </tr>
                    </table>
                </td>
                <!--<td rowspan="10" width="0" bgcolor="#000000"></td>-->
                <td rowspan="10" width="50%" height="100%" background="images/bg1223.jpg" style="background-position:left top; background-repeat:repeat-y"></td>
            </tr>
            <tr>
                <td width="780" height="30" align="center" valign="bottom" background="images/footer.gif"></td>
            </tr>
            <tr>
                <td height="583" valign="top" style="background-repeat:repeat-y;" >
                <br><br><br><br><br><br><br>
              <center>
                    <form action="/cse/login/login1_check.jsp" name="first" method="post">
                        <table width="25%" height="90" border="0" class='formtable1'>
                            <caption align="top">
                              <strong> User Login </strong>
                              <br>
                            </caption>
                            <tr>
                            </tr>
                            <tr>
                                <td width="24%" height="32">
                                    <div align="right"> User ID: </div>
                                </td>
                                <td width="76%">
                                    <label>
                                        <input name="uid" type="text" >
                                    </label>
                                </td>
                            </tr>
                            <tr>
                                <td height="43">
                                    <div align="right"> Password: </div>
                                </td>
                                <td>
                                    <label>
                                        <input name="password" type="password" >
                                    </label>
                                </td>
                            </tr>
                        </table>
                        <input type="submit" name="sub" value="Login">
                    </form>
                 </center>`enter code here`

说用户名是 user,密码是pass

它应该自动填充并单击提交按钮。Visual Basic 10.0 的代码是什么?

4

2 回答 2

1

尝试这个:

If Not String.IsNullOrEmpty(My.Settings.Username) And Not String.IsNullOrEmpty(My.Settings.Password) Then
        TxtUsername.Text = My.Settings.Username
        TxtPassword.Text = My.Settings.Password
End If
于 2013-06-19T14:25:54.243 回答
0

您首先需要获取要与之交互的所有元素。如果他们有 ID,则无需搜索,只需获取以下元素:

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

如果没有,您需要搜索您的,例如:

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

要设置输入值:

elem.SetAttributte("value", passwordVar)

要单击可点击元素(例如提交输入):

elem.InvokeMember("submit")

或者:

elem.InvokeMember("click")
于 2013-06-19T14:54:33.237 回答