电竞比分网-中国电竞赛事及体育赛事平台

分享

VFP控制IE實(shí)例

 Alkaid2015 2013-11-20
post by 劉少 / 2010-2-18 21:54 Thursday

想想我曾是狐友啊,放棄多年了 最近為了種菜偷菜,想用VFP寫(xiě)個(gè)小軟件,想再學(xué)習(xí)下,找到趙老師一票好帖子,特意收藏下:

http://bbs./dispbbs.asp?boardid=81&replyid=291222&id=62506&skin=0&page=1&star=2

QTE

寫(xiě)這個(gè)帖子,是為了與 abiao 交流一下,也告訴FOXER一個(gè)技巧,即如何寫(xiě)程序操作已打開(kāi)的網(wǎng)頁(yè),這個(gè)方法兩、三年前我就摸索掌握了,對(duì)我而言也是一個(gè)秘籍,現(xiàn)奉獻(xiàn)給大家,希望大家給我一個(gè)好評(píng)吧!!!

關(guān)鍵知識(shí)點(diǎn):

1、獲得SHELL對(duì)象
oshell=createobject("shell.application")

2、獲得WINDOW()對(duì)象,此對(duì)象包含所有打開(kāi)的網(wǎng)頁(yè)與文件夾對(duì)象
ow=oshell.windows()

下面貼出我寫(xiě)的程序,用于讀寫(xiě)某網(wǎng)頁(yè)(已打開(kāi)的登機(jī)易)


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="登機(jī)易"
if ffound
=messagebox("請(qǐng)只打開(kāi)一個(gè)登機(jī)易網(wǎng)頁(yè)!")
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,"受理單號(hào):","受理單號(hào):"+sldh)
wystr=strtran(wystr,"受理日期:","受理日期:"+ct3)
wystr=strtran(wystr,"派單日期:","派單日期:"+pdrq)
wystr=strtran(wystr,"派單人員:","派單人員:"+pdry)
wystr=strtran(wystr,"聯(lián)系人 :","聯(lián)系人 :"+ct6)
wystr=strtran(wystr,"聯(lián)系電話:","聯(lián)系電話:"+ct8)
wystr=strtran(wystr,"客戶地址:","客戶地址:"+ct7)

ffound=.T.

endif
endif
endfor

endif

rele oshell
rele ow

if ffound=.f.
=messagebox("沒(méi)有已打開(kāi)的登機(jī)易網(wǎng)頁(yè)!")
endif

thisform.edit1.setfocus
return

UNQTE

 

【ow.item(i).document.getElementById("Detail_Grid").rows(1).cells(2).innertext】這是讀網(wǎng)頁(yè)中ID為"Detail_Grid"的.表格中第2行第3列的內(nèi)客。

 

如網(wǎng)頁(yè)表單中的輸入框的ID為"Khdz_Txt"是客戶地址輸入框,以下這條語(yǔ)句就可給它錄入信息。

ow.item(i).document.getElementById("Khdz_Txt").value="??谑泻5閸u"


 

大家可以測(cè)試一下,看搜索輸入框中是否輸入了內(nèi)容

1、打開(kāi)網(wǎng)易的主頁(yè) WWW.163.com

2、運(yùn)行以下代碼

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="網(wǎng)易"
if ffound
=messagebox("請(qǐng)只打開(kāi)一個(gè)網(wǎng)易網(wǎng)頁(yè)!")
exit for
ENDIF
*!* 在網(wǎng)易的搜索輸入框中輸入文本----梅子論壇VFP技巧
ow.item(i).document.getElementById("q").value="梅子論壇VFP技巧"
ffound=.T.
endif
endif
endfor
endif

rele oshell
rele ow

if ffound=.f.
=messagebox("沒(méi)有已打開(kāi)的網(wǎng)易網(wǎng)頁(yè)!")
endif

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多