奉献个例子,便于理解。
#include <ie.au3>
$oIE=_IECreate("http://www.hao123.com",1 ,1,1,-1)
;~ Sleep(10000)
_IELinkClickByTitle($oIE, '把hao123设为主页')
Func _IELinkClickByTitle(ByRef $o_object, $s_linktext, $i_index = 0, $f_wait = 1)
Local $found = 0, $linktext, $links = $o_object.document.links
$i_index = Number($i_index)
For $link In $links
$linktext = $link.Title & ""
;~ MsgBox(0, '', $linktext)
;~ ContinueLoop
If $linktext = $s_linkText Then
If ($found = $i_index) Then
$link.click
If $f_wait Then
_IELoadWait($o_object)
Return SetError(@error, 0, -1)
EndIf
Return SetError($_IEStatus_Success, 0, -1)
EndIf
$found = $found + 1
EndIf
Next
Return SetError($_IEStatus_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both
EndFunc ;==>_IELinkClickByTitle
|