Board logo

标题: 请教VBS实现对网页自动选择列表框的值 [打印本页]

作者: heicai     时间: 2008-6-22 09:07    标题: 请教VBS实现对网页自动选择列表框的值


'On Error Resume Next
Set Wshell=WScript.CreateObject("WScript.Shell")
Set ie=WScript.CreateObject("InternetExplorer.Application")ie.navigate "https://edit.yahoo.com/registration?"
While ie.ReadyState<>4
Wscript.Sleep 200
Wend
ie.document.getElementById("mm").Options[2].Selected=true
最后这句是不是有问题?我想向列表框选择值。mm是月份的列表框。我想取第二个值
请各位老师指点一二!

[ Last edited by heicai on 2008-6-22 at 09:08 AM ]
作者: slore     时间: 2008-6-22 10:05
ie.document.getElementById("mm").value=2
作者: heicai     时间: 2008-6-22 10:14
感激不尽。谢谢楼上的
作者: heicai     时间: 2008-6-22 10:19
#include "IE.au3"
$oIE=_IECreate ("https://edit.yahoo.com/registration?",0,0)
$oForm=_IEFormGetObjByName ($oIE, "regFormBody")

$oQuery = _IEFormElementGetObjByName ($oForm, "tos_agreed")
_IEFormElementCheckboxSelect($oQuery,1, "", 1, "byIndex")

不知道楼上的懂不懂AutoIt??我想问多选框的勾选。我不知道怎么操作。

[ Last edited by heicai on 2008-6-22 at 10:28 AM ]
作者: heicai     时间: 2008-6-22 11:00


  Quote:
Originally posted by slore at 2008-6-22 10:05 AM:
ie.document.getElementById("mm").value=2

ie.document.getElementById("mm").value=2 确实有效,可是同个页面另两个选择框同样方法就取不到值了。这是为什么呢??
ie.document.getElementById("gender").value=2
ie.document.getElementById("secquestion").value=1
作者: slore     时间: 2008-6-22 13:35
ie.Document.getElementById("mm").value = 2
ie.Document.getElementById("gender").value = "m"
ie.Document.getElementById("secquestion").value = "What was the name of your first school?"
作者: slore     时间: 2008-6-22 13:36
AutoIt
没有用过。。。
作者: heicai     时间: 2008-6-22 13:51


  Quote:
Originally posted by slore at 2008-6-22 01:35 PM:
ie.Document.getElementById("mm").value = 2
ie.Document.[ ...

高手能否PM我你的QQ号码!敬佩
作者: slore     时间: 2008-6-22 14:15
。。。

实在不好提的问题就直接PM我好了……QQ都不怎么上的……
马上回学校,学校限电。。。网都不上的。用处不大。
作者: heicai     时间: 2008-6-22 14:45
Set ie=WScript.CreateObject("InternetExplorer.Application")

WScript.CreateObject的返回值赋给 ie,我希望不再次创建页面,能否在已存在页面上也获得这样的返回值?
因为我希望由我手动打开网址,然后进行文本框、列表框的赋值选择
能否实现??
作者: slore     时间: 2008-6-22 14:47
Set Wshell = WScript.CreateObject("WScript.Shell")
Set ie = WScript.CreateObject("InternetExplorer.Application")
ie.visible = True
ie.navigate "https://edit.yahoo.com/registration?"
While ie.ReadyState <> 4
    Wscript.Sleep 200
Wend
作者: heicai     时间: 2008-6-22 14:50
不是要这样。我是想手动打开IE访问到这个注册页面。
然后当我双击VBS时自动填表。
作者: slore     时间: 2008-6-22 16:04
那样的话只能sendkeys模拟按键。

必须由脚本创建的IE对象才可以那样操作。
作者: heicai     时间: 2008-6-22 16:12


  Quote:
Originally posted by slore at 2008-6-22 04:04 PM:
那样的话只能sendkeys模拟按键。

必须由脚本创建的IE对象才可以那样操作。

sendkeys不是我所要的结果。

因为那样貌似不能选择列表框勾选多选框了。
而且发送过程中我点到什么就会发错位置了吧
是吗?