Content

vbscript网页模拟登录效果代码(用vb编写登录界面代码)满满干货

文章摘要

这篇文章介绍了在Windows环境下使用C#脚本实现的“自动登录”功能,具体针对CMCC-EDU系统。脚本的主要步骤包括: 1. 启动Windows Shell并创建相关对象(文件系统对象和InternetExplorer对象)。 2. 读取“帐号.txt”文件中的用户名和密码。 3. 在浏览器(如百度)上进行操作,包括打开网页、输入用户名和密码、点击登录按钮。 4. 使用脚本循环遍历网页元素,找到并点击“登录”按钮完成操作。 文章重点描述了自动化登录过程的实现原理及其在CMCC-EDU系统中的应用场景。

 ‘自动登录CMCC-EDU ‘By:Seven 2014/2/25 On Error Resume Next Set WshShell=CreateObject(“wscript.Shell”) Set fso=CreateObject(“scripting.filesystemobject”) Set ie=CreateObject(“InternetExplorer.Application”) Set list=fso.OpenTextFile(“帐号.txt”) ie.Visible=1 ie.Navigate “www.baidu.com” Do Until ie.ReadyState=4 : WScript.Sleep 200 : Loop ie.document.getElementByIdx_x(“bpssUSERNAME”).Value=List.ReadLine ie.document.getElementByIdx_x(“bpssBUSPWD”).Value=List.ReadLine Set AllElement=ie.Document For i=0 To AllElement.all.length-1 if AllElement.all(i).tagname=”INPUT” Then if AllElement.all(i).value=”登录” Then AllElement.all(i).click End If End if Next