Function Reference


Create an Internet Explorer Browser Window

#include <IE.au3>
_IECreate ( [$sUrl = "about:blank" [, $iTryAttach = 0 [, $iVisible = 1 [, $iWait = 1 [, $iTakeFocus = 1]]]]] )


$sUrl [optional] specifies the Url to navigate to upon creation
$iTryAttach [optional] specifies whether to try to attach to an existing window
    0 = (Default) do not try to attach
    1 = Try to attach to an existing window
$iVisible [optional] specifies whether the browser window will be visible
    0 = Browser Window is hidden
    1 = (Default) Browser Window is visible
$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
$iTakeFocus [optional] specifies whether to bring the attached window to focus
    0 = Do not bring window into focus
    1 = (Default) bring window into focus

Return Value

Success: an object variable pointing to an InternetExplorer.Application object.
Failure: sets the @error flag to non-zero.
@error: 1 ($_IEStatus_GeneralError) - General Error
3 ($_IEStatus_InvalidDataType) - Invalid Data Type
4 ($_IEStatus_InvalidObjectType) - Invalid Object Type
6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout
8 ($_IEStatus_AccessIsDenied) - Access Is Denied
9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: Set to true (1) or false (0) depending on the success of $iTryAttach


When using tryAttach, a No Match error will be displayed to the console from _IEAttach().
This can be controlled with _IEErrorNotify().

When opening a local HyperTextApplication (.hta) file, Internet Explorer will open a new browser process for it that will not be accessible through the object variable returned by _IECreate().
To control this new browser you must use _IEAttach() with the "embedded" option.

New security in Windows Vista causes a new browser window to be created when a browser is instructed to navigate to a URL in a different security zone.
This occurs as well with the initial creation and navigation initiated with _IECreate().
The new window is a new browser instance and the previous browser object variable no longer points to it.
There are several workarounds:
    1) add #RequireAdmin to your code (this is required even if the account is part of the Administrator's Group and will prompt for credentials if necessary),
    2) use _IEAttach() to connect to the new browser window
    3) add the target website to the Trusted Sites security zone in IE,
    4) turn off "Protected Mode" in IE,
    or 5) disable UAC. Care must be taken to understand the implications of disabling IE security features when accessing untrusted sites.


_IEAttach, _IECreateEmbedded, _IELoadWait, _IENavigate, _IEQuit


Example 1

; Create a browser window and navigate to a website

#include <IE.au3>

Local $oIE = _IECreate("")

Example 2

; Create new browser windows pointing to each of 3 different URLs
; if one does not already exist ($f_tryAttach = 1)
; do not wait for the page loads to complete ($f_wait = 0)

#include <IE.au3>

_IECreate("", 1, 1, 0)
_IECreate("", 1, 1, 0)
_IECreate("", 1, 1, 0)

Example 3

; Attempt to attach to an existing browser displaying a particular website URL
; Create a new browser and navigate to that site if one does not already exist

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("", 1)
; Check @extended return value to see if attach was successful
If @extended Then
        MsgBox($MB_SYSTEMMODAL, "", "Attached to Existing Browser")
        MsgBox($MB_SYSTEMMODAL, "", "Created New Browser")

Example 4

; Create an empty browser window and populate it with custom HTML

#include <IE.au3>

Local $oIE = _IECreate()
Local $sHTML = "<h1>Hello World!</h1>"
_IEBodyWriteHTML($oIE, $sHTML)

Example 5

; Create a browser window attached to a new instance of iexplore.exe
; This is often necessary in order to get a new session cookie context
; (session cookies are shared among all browser instances sharing the same iexplore.exe)

#include <IE.au3>

Opt("WinTitleMatchMode", 2)

ShellExecute("iexplore.exe", "about:blank")
WinWait("Windows Internet Explorer")

Local $oIE = _IEAttach("about:blank", "url")
_IENavigate($oIE, "")