2014-01-30 41 views
0

我想選擇一個按鈕,並提交索引,而不是通過AutoIt名稱。爲什麼我不能用_IEFormElementGetObjByName的原因是因爲有兩個頁面上的按鈕,並且它們都具有相同的名稱,當我檢查元素:AutoIt使用_IEFormElementGetCollection

按鈕1:<input type="submit" name="fsubmit" value="New Upload">"

按鈕2:<input type="submit" name="fsubmit" value="Return to Login Page">

我需要區分這兩者之間的選擇之一。我很確定我應該使用_IEFormElementGetCollection通過表單元素索引號來選擇按鈕。如果還有其他方法可行,我也樂於接受建議。

謝謝!

編輯:這是我最終做的,它似乎工作得很好。在這種情況下

Local $oIE = _IEAttach("WEBSITE NAME") 
Local $oForm = _IEFormGetCollection($oIE, 0) 
; _IEFormElementGetCollection 4 is New Upload, use caution! 
Local $oSubmit = _IEFormElementGetCollection($oForm, 4) 
; Set to focus only for now, when ready to really upload, change "focus" to "click" 
_IEAction($oSubmit, "focus") 
_IELoadWait($oIE) 

回答

0

最安全的方式將是,

Local $oInputs = _IETagNameGetCollection($oIE, "input") 
For $oInput In $oInputs 
    if $oInput.name == "fsubmit" And $oInput.value == "Return to Login Page" Then 
     ; your code here 
    Endif 
Next 

或者,如你所說,

_IETagNameGetCollection($oIE, "input", 1); returns second input