Attach to the specified instance of Internet Explorer where the search string sub-string matches (based on the selected mode).
#include <IE.au3>
_IEAttach($s_string [, $s_mode = "Title" [, $i_instance = 1]])
| $s_string | String to search for (for "embedded" or "dialogbox", use Title sub-string or HWND of window) |
| $s_mode | [optional] specifies search mode Title = (Default) sub-string of main document title WindowTitle = sub-string of full window title (instead of document title) URL = sub-string or url of the current page Text = sub-string in text from the body of the current page HTML = sub-string in html from the body of the current page HWND = hwnd of the browser window Embedded = title sub-string or hwnd of of the window embedding the control DialogBox = title sub-string or hwnd of modal/modeless dialogbox Instance = $s_string is ignored, one browser reference returned (by matching instance number) from all available browser instances |
| $i_instance | [optional] 1-based index into group of browsers or embedded browsers matching $s_string and $s_mode. See Remarks. |
| Success: | Returns an object variable pointing to the InternetExplorer Object for all but Embedded and DislogBox modes which return a Window Object |
| Failure: | Returns 0 and sets @ERROR |
| @Error: | 0 ($_IEStatus_Success) = No Error |
| 5 ($_IEStatus_InvalidValue) = Invalid Value | |
| 7 ($_IEStatus_NoMatch) = No Match | |
| @Extended: | Contains invalid parameter number |
; *******************************************************
; Example 1 - Attach to a browser with "AutoIt" in its title, display the URL
; *******************************************************
#include <IE.au3>
Local $oIE = _IEAttach("AutoIt")
MsgBox(0, "The URL", _IEPropertyGet($oIE, "locationurl"))
; *******************************************************
; Example 2 - Attach to a browser with "The quick brown fox"
; in the text of it's top-level document
; *******************************************************
#include <IE.au3>
$oIE = _IEAttach("The quick brown fox", "text")
; *******************************************************
; Example 3 - Attach to a browser control embedded in another window
; *******************************************************
#include <IE.au3>
$oIE = _IEAttach("A Window Title", "embedded")
; *******************************************************
; Example 4 - Attach to the 3rd browser control embedded in another window
; Use the advanced window title syntax to use the 2nd window
; with the string 'ICQ' in the title
; *******************************************************
#include <IE.au3>
$oIE = _IEAttach("[REGEXPTITLE:ICQ; INSTANCE:2]", "embedded", 3)
; *******************************************************
; Example 5 - Create an array of object references to all current browser instances
; The first array element will contain the number of instances found
; *******************************************************
#include <IE.au3>
Local $aIE[1]
$aIE[0] = 0
Local $i = 1
While 1
$oIE = _IEAttach("", "instance", $i)
If @error = $_IEStatus_NoMatch Then ExitLoop
ReDim $aIE[$i + 1]
$aIE[$i] = $oIE
$aIE[0] = $i
$i += 1
WEnd
MsgBox(0, "Browsers Found", "Number of browser instances in the array: " & $aIE[0])