我想实现以下功能: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
复制代码 附件不支持RAR格式我把格式换成.TXT大家下载后改成.rar即可
[ 本帖最后由 ltnetbar 于 2009-5-15 14:40 编辑 ] |