Call main()
Sub main()
ConfigReat()
End Sub
Sub ConfigReat()
dim fh1 'as fso
dim f
Dim x
Set fh1=createobject("scripting.filesystemobject")'fso文件操作对象
Set f=fh1.opentextfile(environment("configure"),1,false)
Do while f.atendofline<>true
strope=f.readline
x=split(strope,"=") 'x为数组 从0开始 例如:x(0),x(1)
if(instr(x(1),",")<>0) then
xx=split(x(1),",")
For i=lbound(xx) to ubound(xx)
Select Case xx(i)
Case "A" autudata()
Case "S" sqla()
Case "F" readfile()
Case "E" readexcel()
Case else msgbox "System Wrong"
End Select
Next
else
Select Case x(1)
Case "A" autudata()
Case "S" sqla()
Case "F" readfile()
Case "E" readexcel()
Case else msgbox "system Wrong"
End Select
end if
Loop
f.close
Set f=nothing
Set fh1=nothing
End Sub
Sub sqla()
systemutil.CloseProcessByName("calc.exe")
Dim conn
Dim rst
systemutil.Run environment("softwaredir")
Set conn=createobject("adodb.connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\script4\data.mdb;Persist Security Info=False"
'conn.open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=data;Data Source=51TESTING017"
Set rst=createobject("adodb.recordset")
rst.open "select * from data",conn
rst.movefirst
Do while rst.eof<>true
test1=trim(cstr(rst.fields(1)))
test2=trim(cstr(rst.fields(2)))
test3=trim(cstr(rst.fields(3)))
For i=1 to len(test1)
str1=mid(test1,i,1)
window("计算器").WinButton(str1).click
Next
If test3="+" Then
environment("jia")=environment("jia")+1
End If
If test3="-" Then
environment("jian")=environment("jian")+1
End If
If test3="*" Then
environment("chen")=environment("chen")+1
End If
If test3="/" Then
environment("chu")=environment("chu")+1
End If
window("计算器").WinButton(test3).click
For i=1 to len(test2)
str2=mid(test2,i,1)
window("计算器").WinButton(str2).click
Next
window("计算器").WinButton("=").click
addnum cint(test1),cint(test2),test3
rst.movenext
Loop
rst.close
Set rst=nothing
conn.close
Set conn=nothing
systemutil.CloseProcessByName("calc.exe")
End Sub
Sub autudata()
systemutil.CloseProcessByName("calc.exe")
systemutil.Run environment("softwaredir")
icase = int(InputBox("Enter Number"))
For i=1 to icase
key1=Int((100 * Rnd) + 1)
For j=1 to len(key1)
key11=mid(key1,j,1)
window("计算器").WinButton(key11).Click
Next
'msgbox key1
key2=Int((5 * Rnd) ) mod 4
Select Case key2
Case "0" window("计算器").WinButton("+").Click
environment("jia")=environment("jia")+1
Case "1" window("计算器").WinButton("-").Click
environment("jian")=environment("jian")+1
Case "2" window("计算器").WinButton("*").Click
environment("chen")=environment("chen")+1
Case "3" window("计算器").WinButton("/").Click
environment("chu")=environment("chu")+1
Case else msgbox "System wrong"
End Select
' msgbox key2
key3=Int((100 * Rnd) + 1)
For j=1 to len(key3)
key31=mid(key3,j,1)
window("计算器").WinButton(key31).Click
Next
' msgbox key3
window("计算器").WinButton("=").Click
'msgbox cstr(key1)+" "+cstr(key2)+" "+cstr(key3)
If key2=0 Then
addnum key1,key3,"+"
End If
If key2=1 Then
addnum key1,key3,"-"
End If
If key2=2 Then
addnum key1,key3,"*"
End If
If key2=3 Then
addnum key1,key3,"/"
End If
Next
systemutil.CloseProcessByName("calc.exe")
End Sub
Sub readfile()
systemutil.CloseProcessByName("calc.exe")
systemutil.Run environment("softwaredir")
dim fh1 'as fso
dim f
Dim x
Set fh1=createobject("scripting.filesystemobject")'fso文件操作对象
Set f=fh1.opentextfile(environment("datafile"),1,false)
Do while f.atendofline<>true
strope=f.readline
x=split(strope,",") 'x为数组 从0开始 例如:x(0),x(1)
For j=1 to len(x(0))
ch=mid(x(0),j,1)
'msgbox ch
window("计算器").WinButton(ch).Click
Next
If x(2)="+" Then
environment("jia")=environment("jia")+1
End If
If x(2)="-" Then
environment("jian")=environment("jian")+1
End If
If x(2)="*" Then
environment("chen")=environment("chen")+1
End If
If x(2)="/" Then
environment("chu")=environment("chu")+1
End If
For j=1 to len(x(2))
ch=mid(x(2),j,1)
'msgbox ch
window("计算器").WinButton(ch).Click
Next
For j=1 to len(x(1))
ch=mid(x(1),j,1)
'msgbox ch
window("计算器").WinButton(ch).Click
Next
For j=1 to len(x(3))
ch=mid(x(3),j,1)
'msgbox ch
window("计算器").WinButton(ch).Click
Next
addnum x(0),x(1),x(2)
Loop
f.close
Set f=nothing
Set fh1=nothing
systemutil.CloseProcessByName("calc.exe")
End Sub
Sub readexcel
systemutil.CloseProcessByName("calc.exe")
datatable.Import "D:\script_yang\data\data.xls"
iRowCount=datatable.GetSheet("Global").getrowcount
datatable.SetCurrentRow(0)
For i=1 to iRowCount
systemutil.Run environment("softwaredir")
If datatable("oper",dtglobalsheet)="+" Then
environment("jia")=environment("jia")+1
End If
If datatable("oper",dtglobalsheet)="-" Then
environment("jian")=environment("jian")+1
End If
If datatable("oper",dtglobalsheet)="*" Then
environment("chen")=environment("chen")+1
End If
If datatable("oper",dtglobalsheet)="/" Then
environment("chu")=environment("chu")+1
End If
For j=1 to len(datatable("key1",dtglobalsheet))
chkey=mid(datatable("key1",dtglobalsheet),j,1)
window("计算器").WinButton(chkey).click
Next
window("计算器").WinButton(datatable("oper",dtglobalsheet)).click
For j=1 to len(datatable("key2",dtglobalsheet))
chkey=mid(datatable("key2",dtglobalsheet),j,1)
window("计算器").WinButton(chkey).click
Next
window("计算器").WinButton("=").click
addnum datatable("key1",dtglobalsheet),datatable("key2",dtglobalsheet),datatable("oper",dtglobalsheet)
datatable.SetNextRow
systemutil.CloseProcessByName("calc.exe")
Next
End Sub
Sub addnum(ByVal key1,ByVal key2,ByVal key3)
Dim fh1
Dim f
If key3="+" Then
iResult=cint(key1)+cint(key2)
End If
If key3="-" Then
iResult=cint(key1)-cint(key2)
End If
If key3="*" Then
iResult=cint(key1)*cint(key2)
End If
If key3="/" Then
iResult=cint(key1)/cint(key2)
End If
x=window("计算器").WinEdit("Edit").GetROProperty("text")
if (cstr(iResult)+". "=x) then
result="pass"
else
result="failed"
end if
Set fh1=createobject("scripting.filesystemobject")'fso文件操作对象
Set f=fh1.opentextfile(environment("writefile"),8,true)
If key3="+" Then
f.WriteLine "cale_jia_"+cstr(environment("jia"))+" "+cstr(key1)+" "+cstr(key2)+" "+cstr(key3)+" "+cstr(iResult)+". "+" "+x+" "+result
End If
If key3="-" Then
f.WriteLine "cale_jian_"+cstr(environment("jian"))+" "+cstr(key1)+" "+cstr(key2)+" "+cstr(key3)+" "+cstr(iResult)+". "+" "+x+" "+" "+result
End If
If key3="*" Then
f.WriteLine "cale_chen_"+cstr(environment("chen"))+" "+cstr(key1)+" "+cstr(key2)+" "+cstr(key3)+" "+cstr(iResult)+". "+" "+x+" "+" "+result
End If
If key3="/" Then
f.WriteLine "cale_chu_"+cstr(environment("chu"))+" "+cstr(key1)+" "+cstr(key2)+" "+cstr(key3)+" "+cstr(iResult)+". "+" "+x+" "+" "+result
End If
End Sub
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
自录QTP9.0脚本 (1534个子文件)
ObjectRepository.bdb 304KB
ObjectRepository.bdb 304KB
ObjectRepository.bdb 192KB
ObjectRepository.bdb 192KB
default.cfg 1KB
default.cfg 1KB
calc.exe 112KB
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
InstallNewReport.html 695B
共 1534 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
yjjgenery
- 粉丝: 7
- 资源: 44
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论2