呵呵,我也来做一个,对象名称有调整.另外脚本从完成登录,点开车票预订界面后开始执行.解决了输入的问题- Dim strFrom, strTo, strDate
- strFrom = inputBox("出发地")
- strTo = inputBox("目的地")
- strDate = inputBox("出发日期,格式如2013-01-01")
- 'strFrom = "上海"
- 'strTo = "北京"
- 'strDate = "2013-02-02"
- Browser("12306").Page("NewOrder").Frame("main").WebEdit("FromCity").Set ""
- Browser("12306").Page("NewOrder").Frame("main").WebEdit("FromCity").Click 1,1
- Set oClp = CreateObject("Mercury.Clipboard")
- oClp.Clear
- oClp.SetText strFrom
- Set oWsh = CreateObject("Wscript.shell")
- oWsh.SendKeys "^v"
- Set oCityList = Browser("12306").Page("NewOrder").Frame("main").Object.getElementById("panel_cities").ChildNodes
- For i = 0 to oCityList.length -1
- If oCityList(i).ChildNodes(0).innertext=strFrom then
- For j = 0 to i-1
- oWsh.SendKeys "{DOWN}"
- Next
- oWsh.SendKeys "{ENTER}"
- Exit for
- end if
- Next
- Set oCityList = Nothing
- Browser("12306").Page("NewOrder").Frame("main").WebEdit("ToCity").Set ""
- Browser("12306").Page("NewOrder").Frame("main").WebEdit("ToCity").Click 1,1
- oClp.Clear
- oClp.SetText strTo
- oWsh.SendKeys "^v"
- wait 1
- Set oCityList = Browser("12306").Page("NewOrder").Frame("main").Object.getElementById("panel_cities").ChildNodes
- For i = 0 to oCityList.length -1
- print oCityList(i).ChildNodes(0).innerhtml
- If oCityList(i).ChildNodes(0).innertext=strTo then
- print i
- For j = 0 to i-1
- oWsh.SendKeys "{DOWN}"
- Next
- wait 1
- oWsh.SendKeys "{ENTER}"
- Exit for
- end if
- Next
- Set oCityList = Nothing
- Set oWsh = Nothing
- Set oClp = Nothing
- Browser("12306").Page("NewOrder").Frame("main").WebEdit("TrainDate").Object.innerText = strDate
- Browser("12306").Page("NewOrder").Frame("main").WebButton("Select").Click
复制代码 |