工作中调试操作,由人工来做,即浪费精力,又不能体现工作价值;而让电脑代替我们做是一个比较好的选择。
在工作利用VBScript代替人工操作确实带来了不少便利,现记录共享如下:
(当然VBScript本身还是很强大的,这里只利用很简单的操作)
简单示例(循环向串口发送提示和操作命令):
---------------------------------------------
#$language = "VBScript"
#$interface = "1.0"
Sub main
Dim index
index = 1
Do while (index<31)
crt.Screen.Send "#"
crt.Screen.Send Now & VbCr
crt.Screen.Send "cmd" & VbCr
crt.Sleep 50
crt.Screen.Send "" & VbCr
index = index + 1
Loop
End Sub
--------------------------------------------------------------
#行为注释说明,VBScript,1.0版本
Sub为函数入口,main为主入口。
Dim用于声明变量
Do while(条件)
Loop为循环
End Sub为函数结束
crt.Screen.Send为向目标输出内容
示例中的Now为Windows下获取时间的接口
VbCr为换行
crt.Sleep为休眠多少ms