VBS一键配置VOIP(其中包括VBS操作JS网页中的按钮事件--直接执行确认按钮中的脚本代码)

Dim ws,fso,IE
Set IE = WScript.createobject("InternetExplorer.Application")
Set ws = WScript.CreateObject ("WSCript.shell")
Set fso=CreateObject("scripting.filesystemobject")

Const reboot="/content.cgi?form=M_SAV"

IE.menubar=0 ‘显示IE对象菜单栏
IE.AddressBar=1 ‘显示IE对象地址栏
IE.ToolBar=0 ‘显示IE对象工具栏
IE.StatusBar=1 ‘不显示IE对象状态栏
IE.FullScreen=0 ‘全屏化IE对象
IE.Height=768
IE.Width=1024
IE.Resizable=1 ‘设置IE对象大小是否可以被改动
IE.visible=1 ‘设置是否可见 

‘IE.Navigate "192.168.46.3"

‘==============读Config配置文件=========
    
filepath=createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
file_config=filepath&"\config.ini"
Set file=fso.OpenTextFile(file_config,1)
    
‘===========取第一行数据:号码==============
OneLine=file.ReadLine
OneLineStr=Split(OneLine,"=")
OneLineCount=UBound(split(OneLine,"="))
‘MsgBox OneLineStr(1)                   

    
‘===============取第二行数据:密码===========
TwoLine=file.ReadLine
TwoLineStr=Split(TwoLine,"=")
TwoLineCount=UBound(split(TwoLine,"="))
‘MsgBox TwoLineStr(1)
    
‘===============取第三行数据:VOIP服务地址============
ThreeLine=file.ReadLine
ThreeLineStr=Split(ThreeLine,"=")
ThreeLineCount=UBound(split(ThreeLine,"="))
‘MsgBox ThreeLineStr(1)
    
‘===============取第四行数据:对讲设备地址============
FourLine=file.ReadLine
FourLineStr=Split(FourLine,"=")
FourLineCount=UBound(split(FourLine,"="))
‘MsgBox FourLineStr(1)
    
‘===============取第五行数据:浏览器安装目录============
FiveLine=file.ReadLine
FiveLineStr=Split(FiveLine,"=")
FiveLineCount=UBound(split(FiveLine,"="))
‘MsgBox FiveLineStr(1)
    
‘MainWeb()

Main()
‘==================================================

Function Main()

    IE.Navigate FourLineStr(1)
        
    Do 
        WScript.Sleep 500
        
    Loop Until IE.ReadyState=4
    
    
    Login()
    SipSetting()
    InputParm()
    VOIP()
    RebootSys()

End Function 
‘======================================================
‘登录系统
Function Login()

    WScript.Sleep 1000
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys "admin"
    ws.SendKeys "{TAB}"
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys "admin"
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{ENTER}"

End Function 
‘================================================
‘进入sipsetting菜单
Function SipSetting()

    If IE.ReadyState=4 Then 
    
        WScript.Sleep 1000
        ws.SendKeys "{TAB 5}"
        WScript.Sleep 500
        ws.SendKeys "{ENTER}"
        WScript.Sleep 500
        ws.SendKeys "{TAB}"
        WScript.Sleep 500
        ws.SendKeys "{ENTER}"
        WScript.Sleep 2000
    Else 
    
     MsgBox "进入配置界面失败!"
     
    End If 

End Function 
‘=============================================
‘切换输入界面
Function InputParm()

    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200    
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    
    
    ws.SendKeys "{DOWN}"  ‘选择开启状态
    WScript.Sleep 300

End Function 
‘=========================================
‘配置参数
Function VOIP()

    ws.SendKeys "{TAB}"
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys OneLineStr(1)  ‘display name
    
    ws.SendKeys "{TAB}"
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys OneLineStr(1)   ‘user number
    
    ws.SendKeys "{TAB}"
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys OneLineStr(1)   ‘auth id
    
    ws.SendKeys "{TAB}"    
    WScript.Sleep 200
    ws.SendKeys "^a"
    WScript.Sleep 200            
    ws.SendKeys TwoLineStr(1)   ‘password
    
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys ThreeLineStr(1)   ‘proxy ip
    
    ws.SendKeys "{TAB}"        ‘domain
    WScript.Sleep 200
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys ThreeLineStr(1)
    
    ‘=============保存===========
    ws.SendKeys "{TAB 48}"
    WScript.Sleep 500
    ws.SendKeys "{TAB}"
    WScript.Sleep 500
    ws.SendKeys "{ENTER}"
    WScript.Sleep 1500
    
End Function 

‘========================================================
‘修改参数后重启
Function RebootSys()

    WScript.Sleep 500
    ws.SendKeys "{F4}"
    WScript.Sleep 500
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys FourLineStr(1)&reboot 
    
    WScript.Sleep 500    
    
‘   Set test=IE.document.getElementsByTagName ("Button")
    ws.SendKeys "{ENTER}"
    
    WScript.Sleep 2000
    
    Set ALL = Ie.Document.getElementsByTagName("input")  ‘检测网页元素是否标签为input,且值等于Reboot

    For Each i In ALL

    If i.value="Reboot" Then

       ‘i.Click  ‘点击reboot按钮
       
        WScript.Sleep 1000
       
        Ie.Document.parentwindow.execScript("top.location=‘content.cgi?_method_=reboot‘")  ‘直接执行reboot确认操作

        Exit For

     
    End If

    Next
    
    WScript.Sleep 3000    
    
    MsgBox "配置已完成,设备正在重启,请耐心等待...",,"提示"

    If ws.AppActivate("来自网页的消息") Then 
    
    
        ws.SendKeys "{ENTER}"
        WScript.Sleep 2000
        
        MsgBox "配置已完成,设备正在重启,请耐心等待...",,"提示"
        
    Else 
        ‘MsgBox "配置未成功,请重新检查配置!",,"提示"
        
    End If 

End Function 

‘====================================================================

Function MainWeb()

    ‘=============启动地址=====================
‘方式一:自定义浏览器启动,需配置路径
‘   Function login()
        
‘       ws.run FiveLineStr(1)
‘       WScript.Sleep 3000
‘       ws.SendKeys "{F4}"
‘       WScript.Sleep 200
‘       ws.SendKeys "^a"
‘       WScript.Sleep 500
‘       ws.SendKeys FourLineStr(1)
‘       WScript.Sleep 500
‘       ws.SendKeys "{ENTER}"
                
‘   End Function    

‘方式二:用系统默认浏览器启动 
    ws.Run FourLineStr(1)

    ‘===============登录设备=====================
    WScript.Sleep 5000
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys "admin"
    ws.SendKeys "{TAB}"
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys "admin"
    ws.SendKeys "{ENTER}"
    
    ‘============进入sip setting菜单=============
    WScript.Sleep 2000
    ws.SendKeys "{TAB 5}"
    WScript.Sleep 500
    ws.SendKeys "{ENTER}"
    WScript.Sleep 500
    ws.SendKeys "{TAB}"
    WScript.Sleep 500
    ws.SendKeys "{ENTER}"
    WScript.Sleep 2000
    
    
    ‘==============进入编辑状态=======================
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200    
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    
    
    
    ws.SendKeys "{DOWN}"  ‘选择开启状态
    WScript.Sleep 300

    
    ‘==============配置VOIP================
    ws.SendKeys "{TAB}"
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys OneLineStr(1)  ‘display name
    
    ws.SendKeys "{TAB}"
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys OneLineStr(1)   ‘user number
    
    ws.SendKeys "{TAB}"
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys OneLineStr(1)   ‘auth id
    
    ws.SendKeys "{TAB}"    
    WScript.Sleep 200
    ws.SendKeys "^a"
    WScript.Sleep 200            
    ws.SendKeys TwoLineStr(1)   ‘password
    
    ws.SendKeys "{TAB}"
    WScript.Sleep 200
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys ThreeLineStr(1)   ‘proxy ip
    
    ws.SendKeys "{TAB}"        ‘domain
    WScript.Sleep 200
    ws.SendKeys "^a"
    WScript.Sleep 200
    ws.SendKeys ThreeLineStr(1)
    
    ‘=============保存===========
    ws.SendKeys "{TAB 48}"
    WScript.Sleep 500
    ws.SendKeys "{TAB}"
    WScript.Sleep 500
    ws.SendKeys "{ENTER}"
    WScript.Sleep 1500
    ‘===============重启==========
    
    ws.SendKeys "{TAB 18}"
    WScript.Sleep 1000
    ws.SendKeys "{ENTER}"
    WScript.Sleep 1000
    ws.SendKeys "{TAB 2}"
    WScript.Sleep 500
    ws.SendKeys "{ENTER}"
    WScript.Sleep 1000
    
    If ws.AppActivate("来自网页的消息") Then 
    
        ws.SendKeys "{ENTER}"
        WScript.Sleep 1000
        
        MsgBox "配置已完成,设备正在重启,请耐心等待...",,"提示"
        
    Else 
        MsgBox "配置未成功,请重新检查配置!",,"提示"
        
    End If 

End Function 

Set ws=Nothing 
Set IE=Nothing 
Set fso=Nothing 

##################################################网页部分JS代码:

<div id="content" width="650">
<form name="M_SAV" method="GET" enctype="multipart/form-data" onReset="" action="content.cgi">
<input type=HIDDEN name="_method_" value="apply">
<input type=HIDDEN name="form" value="M_SAV">
<input type=HIDDEN name="commit" value="0">
<table id="cFORM" width="650" border="0" cellspacing="0" cellpadding="0" >
<tr><td>&nbsp</td></tr>
</table><table width="500"><td align="center">
<input type=BUTTON onclick="javascript:if ( confirm(‘Reboot‘) ) top.location=‘content.cgi?_method_=reboot‘;" target="_top" value="Reboot"></a>
</td></table></form>

VBS一键配置VOIP(其中包括VBS操作JS网页中的按钮事件--直接执行确认按钮中的脚本代码)

时间: 2024-10-15 05:18:00

VBS一键配置VOIP(其中包括VBS操作JS网页中的按钮事件--直接执行确认按钮中的脚本代码)的相关文章

VBS操作JS网页元素实例

'=========================================================================='' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0'' NAME: '' AUTHOR: Microsoft , Microsoft' DATE : 2014/8/14'' COMMENT: ''==========================

物联网(莹石云)WIFI一键配置原理分析(zz)

最近打算做一款自己的无线传输模块用来实现光伏电站的数据接入,希望可以尽量简化接入流程,其中wifi密码的配置就是一个比较麻烦的事情,想到最近使用萤石摄像头时,wifi密码配置似乎很简单,他们是怎么做到的,下面这篇文章很好的解答了这个问题: http://www.ayiii.com/712.html 自从物联网问世以来,如何使得物能够联网有了很多的方式,目前运用非常广的WIFI,今天就总结下自这个方面.物联网:智能硬件+APP+云APP 需要配置wifi用户名 密码进入智能硬件,目前各个WIFI芯

我的openwrt学习笔记(二十六):smartconfig一键配置udp原理

1.一种基于WIFI通信的电子设备接入网方法,其特征在于,所述方法包括: 步骤S1:发送端将需传输的原始数据信息加密为十六进制形式的待发送数据: 步骤S2:发送端将待发送数据以及数据索引加入多播IP地址: 步骤S3:发送端将该多播IP地址映射为对应的多播MAC地址: 步骤S4:发送端重复发出包含该多播MAC地址的多播数据包: 步骤S5:接收端根据事先扫描到的WIFI频道,不断循环扫描WIFI频道,以检测上述发送方发送的多播数据包: 步骤S6:接收端在检测到该多播数据包时获取该多播数据包的多播MA

基于CentOS7系统一键配置Aria2 实现服务器离线下载工具

我们有些网友购买的海外VPS主机并不是用来做网站的,而是用来作为下载资源工具使用的.确实用这样的工具搭建之后是比本地下载速度快,因为有些资源.软件等是海外资源,而且挂载在服务器上不占用本地的资源.在这篇文章中,笔者有看到一个不错的一键脚本,可以快速的在服务器中安装Aria2,实现服务器端的离线下载工具,如果我们也有需要可以一起和我看看如何安装和使用的. 第一.一键脚本下载安装Aria2和特点 1.脚本安装 yum -y install wget unzip curl wget https://g

XINU安装程序.exe一键配置好XINU实验环境 - imsoft.cnblogs

  还在一步一步配置复杂的XINU吗?XINU安装程序.exe一键配置好XINU实验环境. XINU安装程序.exe使用说明: 本程序配合<网络协议分析与实现>/(胡维华等编著)课本使用 本程序会自动解压安装配置好的XINU系统(包含XINU和VPC文件夹)到D盘根目录 解压此程序后,用VPC2007虚拟机软件打开或者导入即可. 附件还包含一系列使用时需要用到的程序,以及笔者自己根据使用需求建立的快捷使用方法. 推荐直接下载:VPC 2007 精简版.exe,XINU安装程序.exe,XINU

linux 自动化一键配置rsync

功能介绍 1.一键配置rsync 2.不支持多模块或者多用户 3.-a一切随机 4.不加-a需要手动输入账号密码 5.进度条只是好看,并不代表真的进度 #!/bin/bashusersuiji=`uuidgen | cut -c 1-10`passwdsuiji=`uuidgen | cut -c 1-10`jindutiao () {COUNTER=0_R=0      _C=`tput cols`_PROCEC=`tput cols` tput cup $_C $_Rprintf "[&qu

物联网 WIFI 一键配置原理(smartconfig) ESP8266/QCA4004 参考

物联网 WIFI 一键配置原理(smartconfig) ESP8266/QCA4004 物联网WIFI 嵌入式爱好者(小子图) · 2015-09-05 11:07 自从物联网问世以来,如何使得物  能够联网有了很多的方式,目前运用非常广的WIFI,今天就总结下自这个方面,也对于有需要的盆友也希望有抛砖引玉之效果. 来看个知乎上的提问,很有意思! 问题: 买了BroadLink的智能插座,发现有一个很神奇的一键配置功能.简单的说就是:当智能插座还没有连上WiFi的时候,此时通过手机App可以将

VBS脚本代码(手工编写)

'=========================================================================='' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.1'' NAME: '' AUTHOR: Windows 用户 , AEBELL' DATE : 2014/7/7'' COMMENT: ''=============================

win2008系统:iis配置备份和还原简单操作

(2013-09-26 16:33:22) 转载▼   分类: 开发类 当我们电脑系统有大量的站点和虚拟目录的时候,电脑因为种种原因需要重做系统,那么重装系统后这些站点我们是否只能一个一个的添加,如果有成百上千个站点呢,任务量可想而知,本文将介绍如何备份和还原win7系统IIS下的站点,重装系统后配置IIS站点将是一件非常轻松的事.笔记本电脑用的WIn7,从买电脑到现在用了有一年多了,一年下来装的软件又多又杂,而且很多软件都被病毒吞噬过,严重的影响开机速度和使用,现在准备重装系统,还我一个清爽的