前此天在问问上写过一个,也是类似于重复获取文件行数,FSO每次都要去读文件,太麻烦,就读到内存,用正则子集分行,速度快一些,改过来看看- Dim objIE,Lines
- CreateIe
- RegExpTest(ReadText("sh.ini"))
-
- Function RegExpTest(string)
- msgbox lines
- Set RegEx1=New RegExp
- RegEx1.Pattern="(.*)(\n)"
- RegEx1.IgnoreCase=True
- RegEx1.Global=True
- Set A=RegEx1.Execute(string)
- Do
- Set AA=A(Int((Lines-1)*rnd))
- BB=AA.SubMatches(0)
- SendWeb BB
- WScript.Sleep 5000
- Loop
- End Function
-
- Sub SendWeb(sText)
- With objIe
- .Navigate "www.baidu.com"
- Do While (.Busy)
- Wscript.Sleep 200
- Loop
- .Visible=1
- .Document.All.wd.Value=sText
- .Document.All.sb.click
- End With
- End Sub
-
- Function CreateIe
- Set objIE=WScript.CreateObject("InternetExplorer.Application","UE_")
- objIE.Navigate("about:blank")
- End Function
-
- Function ReadText(FilePath)
- Dim Fso,Rso
- Set Fso=CreateObject("Scripting.FileSystemObject")
- Set Gso=Fso.GetFile(FilePath)
- Set Rso=Gso.OpenAsTextStream(1)
- ReadText=Rso.ReadAll
- Lines=Rso.Line
- Set Fso=Nothing
- End Function
-
- Sub UE_OnQuit()
- WScript.Quit
- End Sub
复制代码
|