我正在尝试使用csv文件中的邮政编码更新http://www.postcodeanywhere.co.uk/demos/address-finder/ txtAddressSearchSingleField
。到目前为止,我已尝试过以下内容:
fileread, AddressList, mk-data-000001-1.csv
IE := ComObjCreate("InternetExplorer.Application")
ComObjError(false)
IE.Visible := true
loop, parse, AddressList, `n, `r
{
PostCode := A_LoopField
IE.Navigate("http://www.postcodeanywhere.co.uk/demos/address-finder/")
IE.document.getElementById("txtAddressSearchSingleField").value := PostCode
}
;IE.quit()
mk-data-000001-1.csv样本数据
MK4 4FL
MK46 5EF
MK2 2RD
MK12 5EG
MK13 7BX
但它似乎没有起作用 - 任何想法为什么?
答案 0 :(得分:0)
FileRead, AddressList, mk-data-000001-1.csv
IE := ComObjCreate("InternetExplorer.Application")
ComObjError(false)
IE.Visible := true
Loop, Parse, AddressList, `n, `r
{
PostCode := A_LoopField
IE.Navigate("http://www.postcodeanywhere.co.uk/demos/address-finder/")
While IE.readyState != 4 || IE.document.readyState != "complete" || IE.busy
Sleep, 25
IE.document.getElementById("txtAddressSearchSingleField").focus() ;ususally you don't need this, in this case the value won't be visible if you don't do this, but it will still be there.
IE.document.getElementById("txtAddressSearchSingleField").value := PostCode
}
;IE.quit()
主要问题是,您必须等待页面加载,才能可靠地与其进行交互。第二个"问题"是输入字段内容不会显示它的实际值,除非您在更改值之前或之后单击它。一个简单的.focus()调用修复了这个缺陷。