打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
VFP控制IE实例
post by 刘少 / 2010-2-18 21:54 Thursday
想想我曾是狐友啊,放弃多年了 最近为了种菜偷菜,想用VFP写个小软件,想再学习下,找到赵老师一票好帖子,特意收藏下:
http://bbs.meizvfp.com/dispbbs.asp?boardid=81&replyid=291222&id=62506&skin=0&page=1&star=2
QTE
写这个帖子,是为了与 abiao 交流一下,也告诉FOXER一个技巧,即如何写程序操作已打开的网页,这个方法两、三年前我就摸索掌握了,对我而言也是一个秘籍,现奉献给大家,希望大家给我一个好评吧!!!
关键知识点:
1、获得SHELL对象
oshell=createobject("shell.application")
2、获得WINDOW()对象,此对象包含所有打开的网页与文件夹对象
ow=oshell.windows()
下面贴出我写的程序,用于读写某网页(已打开的登机易)
oshell=createobject("shell.application")
ow=oshell.windows()
ffound=.f.
if ow.count>0
for i=0 to (ow.count-1)
if ("IEXPLORE.EXE" $ UPPER(ow.item(i).fullname))
if ow.item(i).document.title="登机易"
if ffound
=messagebox("请只打开一个登机易网页!")
exit for
endif
thisform.text2.value=ow.item(i).document.getElementById("Detail_Grid").rows(1).cells(2).innertext
ct3=ow.item(i).document.getElementById("Slrq_Txt").value
thisform.text3.value=ctod(ct3)
thisform.text5.value=ow.item(i).document.getElementById("Detail_Grid").rows(1).cells(0).innertext
ct6=ow.item(i).document.getElementById("Clxr_Txt").value
thisform.text6.value=ct6
ct8=ow.item(i).document.getElementById("Lxdh_Txt").value
thisform.text8.value=ct8
ct7=ow.item(i).document.getElementById("Khdz_Txt").value
thisform.text7.value=ct7
otable=ow.item(i).document.getElementById("Detail_Grid")
thisform.text9.value=otable.rows(1).cells(6).innertext
thisform.text10.value=otable.rows(1).cells(3).innertext
thisform.text11.value=otable.rows(1).cells(4).innertext
thisform.text12.value=otable.rows(1).cells(5).innertext
thisform.text13.value=otable.rows(1).cells(7).innertext
qtxt=otable.rows(1).cells(8).innertext
thisform.text14.value=ctod(substr(qtxt,1,4)+"/"+substr(qtxt,5,2)+"/"+substr(qtxt,7,2))
thisform.text15.value=otable.rows(1).cells(9).innertext
thisform.text17.value=val(otable.rows(1).cells(10).innertext)
thisform.text19.value=50
thisform.text20.value=val(otable.rows(1).cells(11).innertext)-50
thisform.edit1.value=ow.item(i).document.getElementById("Khyq_Txt").value
sfz=otable.rows(1).cells(1).innertext
sldh=ow.item(i).document.getElementById("Sldh_Txt").value
****pdry 派单人员
pdry=ow.item(i).document.getElementById("Pdry_Txt").value
pdrq=ow.item(i).document.getElementById("Pdrq_Txt").value
wystr=ow.item(i).document.body.innertext
wystr=strtran(wystr,"受理单号:","受理单号:"+sldh)
wystr=strtran(wystr,"受理日期:","受理日期:"+ct3)
wystr=strtran(wystr,"派单日期:","派单日期:"+pdrq)
wystr=strtran(wystr,"派单人员:","派单人员:"+pdry)
wystr=strtran(wystr,"联系人 :","联系人 :"+ct6)
wystr=strtran(wystr,"联系电话:","联系电话:"+ct8)
wystr=strtran(wystr,"客户地址:","客户地址:"+ct7)
ffound=.T.
endif
endif
endfor
endif
rele oshell
rele ow
if ffound=.f.
=messagebox("没有已打开的登机易网页!")
endif
thisform.edit1.setfocus
return
UNQTE
【ow.item(i).document.getElementById("Detail_Grid").rows(1).cells(2).innertext】这是读网页中ID为"Detail_Grid"的.表格中第2行第3列的内客。
如网页表单中的输入框的ID为"Khdz_Txt"是客户地址输入框,以下这条语句就可给它录入信息。
ow.item(i).document.getElementById("Khdz_Txt").value="海口市海甸岛"
大家可以测试一下,看搜索输入框中是否输入了内容
1、打开网易的主页 WWW.163.com
2、运行以下代码
oshell=createobject("shell.application")
ow=oshell.windows()
ffound=.f.
if ow.count>0
for i=0 to (ow.count-1)
if ("IEXPLORE.EXE" $ UPPER(ow.item(i).fullname))
if ow.item(i).document.title="网易"
if ffound
=messagebox("请只打开一个网易网页!")
exit for
ENDIF
*!* 在网易的搜索输入框中输入文本----梅子论坛VFP技巧
ow.item(i).document.getElementById("q").value="梅子论坛VFP技巧"
ffound=.T.
endif
endif
endfor
endif
rele oshell
rele ow
if ffound=.f.
=messagebox("没有已打开的网易网页!")
endif
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
动态创建HTML表格[转载自MSDN]
vfp9.0通过WebBrowser控件获取QQ新闻标题及链接
如何通过js获取表单对象?
js中的DOM操作
使用 VFP 读取 excel 的信息采集表各项内容
span的赋值与取值
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服