标题: [求助]VBS脚本随机输入字符到网页对话框
[打印本页]
作者: ltnetbar
时间: 2009-5-15 22:37
标题: [求助]VBS脚本随机输入字符到网页对话框
我想实现以下功能:vbs随机读取txt文件的字符并在指定IE输入框中输入(复制粘贴)并按回车键等待IE完成响应后关闭IE!
下面是我看别人的脚本示例修改后的另一个实现思路,觉的不理想!最不理想的是VBS控制键盘输入很容易出错,大家有什么好的方法请帮帮忙!并且副上我收集的脚本合集!我不会VBS,还多请各位高手帮帮忙!谢谢!
'简单的打开浏览器浏览某个公共页面
'set huobilie = Wscript.CreateObject("Wscript.Shell")
'huobilie.run "iexplore http://www.baidu.com"
Set ie = Wscript.CreateObject("InternetExplorer.Application")
ie.Navigate "about:blank"
ie.ToolBar = 0
ie.StatusBar = 0
ie.Width=400
ie.Height = 100
ie.Left = 300
ie.Top = 300
SynchronizeIE()
ie.Visible = 1
ie.Document.Body.InnerHTML = "自动输入"
WScript.Sleep 2000
ie.navigate "www.baidu.com"
SynchronizeIE()
Set wshshell=CreateObject("wscript.shell")
wscript.sleep 500
wshshell.Sendkeys"{TAB}"
wshshell.Sendkeys"{TAB}"
wshshell.Sendkeys"{TAB}"
wshshell.Sendkeys"{TAB}"
wshshell.Sendkeys"{TAB}"
wshshell.Sendkeys"{TAB}"
wshshell.Sendkeys"{TAB}"
wshshell.Sendkeys"{TAB}"
wscript.Sleep 500
wshshell.Sendkeys"a"
wshshell.Sendkeys"d"
wshshell.Sendkeys"m"
wshshell.Sendkeys"i"
wshshell.Sendkeys"n"
wshshell.Sendkeys"{ENTER}"
SynchronizeIE()
ie.Visible=1
'WShell.SendKeys "~" ' 回车
'wscript.Sleep 5000
'Wshell.SendKeys "^W" ' 关闭IE窗口
'//等待IE操作结束。
Function SynchronizeIE()
While ie.Busy
WScript.Sleep(100)
Wend
'Do
' Wscript.Sleep 200
'Loop Until ie.ReadyState=4
End Function
下面是bat随机运行VBS的脚本:
@echo off
SET num=%RANDOM%
SET /A (num%%=16)
start C:\new\%num%.vbs
脚本合集下载地址:http://upload.cn-dos.net/img/1497.rar