Function Reference


Simulate a mouse click on a link with text sub-string matching the string provided

#include <IE.au3>
_IELinkClickByText ( ByRef $oObject, $sLinkText [, $iIndex = 0 [, $iWait = 1]] )


$oObject Object variable of an InternetExplorer.Application, Window or Frame object
$sLinkText Text displayed on the web page for the desired link to click
$iIndex [optional] If the link text occurs more than once, specify which instance you want by 0-based index
$iWait [optional] specifies whether to wait for page to load before returning
    0 = Return immediately, not waiting for page to load
    1 = (Default) Wait for page load to complete before returning

Return Value

Success: none.
Failure: 0 or -1 and sets the @error flag to non-zero.
@error: 1 ($_IEStatus_GeneralError) - General Error
2 ($_IEStatus_COMError) - COM Error in Object reference
3 ($_IEStatus_InvalidDataType) - Invalid Data Type
4 ($_IEStatus_InvalidObjectType) - Invalid Object Type
6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout
7 ($_IEStatus_NoMatch) - No Match
8 ($_IEStatus_AccessIsDenied) - Access Is Denied
9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: Contains invalid parameter number


Not all elements that appear to be links actually are.
It is common practice to attach onClick JavaScript events to other DOM elements to simulate the behavior of links.
To activate such elements, use "click" with _IEAction().


_IELinkClickByIndex, _IELoadWait


Example 1

; Open browser with basic example, click on the link with text "user forum"

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IELinkClickByText($oIE, "user forum")

Example 2

; Open browser to the AutoIt homepage, loop through the links
; on the page and click on the link with text "overview"
; using a sub-string match.

#include <IE.au3>

Local $oIE = _IECreate("")

Local $sMyString = "overview"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
        Local $sLinkText = _IEPropertyGet($oLink, "innerText")
        If StringInStr($sLinkText, $sMyString) Then
                _IEAction($oLink, "click")