#include-once #include "AutoItConstants.au3" #include "FileConstants.au3" #include "WinAPIError.au3" ; #INDEX# ======================================================================================================================= ; Title .........: Internet Explorer Automation UDF Library for AutoIt3 ; AutoIt Version : 3.3.14.0 ; Language ......: English ; Description ...: A collection of functions for creating, attaching to, reading from and manipulating Internet Explorer. ; Author(s) .....: DaleHohm, big_daddy, jpm ; Dll ...........: user32.dll, ole32.dll, oleacc.dll ; =============================================================================================================================== #Region Header #cs Title: Internet Explorer Automation UDF Library for AutoIt3 Filename: IE.au3 Description: A collection of functions for creating, attaching to, reading from and manipulating Internet Explorer Author: DaleHohm Modified: jpm, Jon Version: T3.0-1 Last Update: 13/06/02 Requirements: AutoIt3 3.3.9 or higher Update History: =================================================== T3.0-2 14/8/19 Enhancements - Updated __IEErrorHandlerRegister to work with or without COM errors being fatal T3.0-1 13/6/2 Enhancements - Fixed _IE_Introduction, _IE_Examples generate HTML5 - Added check in __IEComErrorUnrecoverable for COM error -2147023174, "RPC server not accessible." - Fixed check in __IEComErrorUnrecoverable for COM error -2147024891, "Access is denied." - Fixed check in __IEComErrorUnrecoverable for COM error -2147352567, "an exception has occurred." - Fixed __IEIsObjType() not restoring _IEErrorNotify() - Fixed $b_mustUnlock on Error in _IECreate() - Fixed no timeout cheking if error in _IELoadWait() - Fixed HTML5 support in _IEImgClick(), _IEFormImageClick() - Fixed _IEHeadInsertEventScript() COM error return - Updated _IEErrorNotify() default keyword support - Updated rename __IENotify() to __IEConsoleWriteError() and restore calling @error - Removed __IEInternalErrorHandler() (not used any more) - Updated Function Headers - Updated doc and splitting and checking examples T3.0-0 12/9/3 Fixes - Removed _IEErrorHandlerRegister() and all internal calls to it. Unneeded as COM errors are no longer fatal - Removed code deprecated in V2 - Fixed _IELoadWait check for unrecoverable COM errors - Removed Vcard support from _IEPropertyGet (IE removed support in IE7) - Code cleanup with #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 New Features - Added "scrollIntoView" to _IEAction Enhancements - Added check in __IEComErrorUnrecoverable for COM error -2147023179, "The interface is unknown." - Added "Trap COM error, report and return" to functions that perform blind method calls (those without return values) =================================================== #ce #EndRegion Header ; #VARIABLES# =================================================================================================================== #Region Global Variables Global $__g_iIELoadWaitTimeout = 300000 ; 5 Minutes Global $__g_bIEAU3Debug = False Global $__g_bIEErrorNotify = True Global $__g_oIEErrorHandler, $__g_sIEUserErrorHandler #EndRegion Global Variables ; =============================================================================================================================== ; #CONSTANTS# =================================================================================================================== #Region Global Constants Global Const $__gaIEAU3VersionInfo[6] = ["T", 3, 0, 2, "20140819", "T3.0-2"] Global Const $LSFW_LOCK = 1, $LSFW_UNLOCK = 2 ; ; Enums ; Global Enum _; Error Status Types $_IESTATUS_Success = 0, _ $_IESTATUS_GeneralError, _ $_IESTATUS_ComError, _ $_IESTATUS_InvalidDataType, _ $_IESTATUS_InvalidObjectType, _ $_IESTATUS_InvalidValue, _ $_IESTATUS_LoadWaitTimeout, _ $_IESTATUS_NoMatch, _ $_IESTATUS_AccessIsDenied, _ $_IESTATUS_ClientDisconnected ;~ Global Enum Step * 2 _; NotificationLevel ;~ $_IENotifyLevel_None = 0, _ ;~ $_IENotifyNotifyLevel_Warning = 1, _ ;~ $_IENotifyNotifyLevel_Error, _ ;~ $_IENotifyNotifyLevel_ComError ;~ Global Enum Step * 2 _; NotificationMethod ;~ $_IENotifyMethod_Silent = 0, _ ;~ $_IENotifyMethod_Console = 1, _ ;~ $_IENotifyMethod_ToolTip, _ ;~ $_IENotifyMethod_MsgBox #EndRegion Global Constants ; =============================================================================================================================== ; #NO_DOC_FUNCTION# ============================================================================================================= ; _IEErrorHandlerRegister ; _IEErrorHandlerDeRegister ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _IECreate ; _IECreateEmbedded ; _IENavigate ; _IEAttach ; _IELoadWait ; _IELoadWaitTimeout ; ; _IEIsFrameSet ; _IEFrameGetCollection ; _IEFrameGetObjByName ; ; _IELinkClickByText ; _IELinkClickByIndex ; _IELinkGetCollection ; ; _IEImgClick ; _IEImgGetCollection ; ; _IEFormGetCollection ; _IEFormGetObjByName ; _IEFormElementGetCollection ; _IEFormElementGetObjByName ; _IEFormElementGetValue ; _IEFormElementSetValue ; _IEFormElementOptionSelect ; _IEFormElementCheckBoxSelect ; _IEFormElementRadioSelect ; _IEFormImageClick ; _IEFormSubmit ; _IEFormReset ; ; _IETableGetCollection ; _IETableWriteToArray ; ; _IEBodyReadHTML ; _IEBodyReadText ; _IEBodyWriteHTML ; _IEDocReadHTML ; _IEDocWriteHTML ; _IEDocInsertText ; _IEDocInsertHTML ; _IEHeadInsertEventScript ; ; _IEDocGetObj ; _IETagNameGetCollection ; _IETagNameAllGetCollection ; _IEGetObjByName ; _IEGetObjById ; _IEAction ; _IEPropertyGet ; _IEPropertySet ; _IEErrorNotify ; _IEQuit ; ; _IE_Introduction ; _IE_Example ; _IE_VersionInfo ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ; __IELockSetForegroundWindow ; __IEControlGetObjFromHWND ; __IERegisterWindowMessage ; __IESendMessageTimeout ; __IEIsObjType ; __IEConsoleWriteError ; __IEComErrorUnrecoverable ; ; __IEInternalErrorHandler ; __IEInternalErrorHandlerRegister ; __IENavigate ; __IECreateNewIE ; __IETempFile ; ; __IEStringToBstr ; __IEBstrToString ; =============================================================================================================================== #Region Core functions ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; Modified ......: jpm ; =============================================================================================================================== Func _IECreate($sUrl = "about:blank", $iTryAttach = 0, $iVisible = 1, $iWait = 1, $iTakeFocus = 1) If Not $iVisible Then $iTakeFocus = 0 ; Force takeFocus to 0 for hidden window If $iTryAttach Then Local $oResult = _IEAttach($sUrl, "url") If IsObj($oResult) Then If $iTakeFocus Then WinActivate(HWnd($oResult.hWnd)) Return SetError($_IESTATUS_Success, 1, $oResult) EndIf EndIf Local $iMustUnlock = 0 If Not $iVisible And __IELockSetForegroundWindow($LSFW_LOCK) Then $iMustUnlock = 1 Local $oObject = ObjCreate("InternetExplorer.Application") If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IECreate", "", "Browser Object Creation Failed") If $iMustUnlock Then __IELockSetForegroundWindow($LSFW_UNLOCK) Return SetError($_IESTATUS_GeneralError, 0, 0) EndIf $oObject.visible = $iVisible ; If the unlock doesn't work we may have created an unwanted modal window If $iMustUnlock And Not __IELockSetForegroundWindow($LSFW_UNLOCK) Then __IEConsoleWriteError("Warning", "_IECreate", "", "Foreground Window Unlock Failed!") _IENavigate($oObject, $sUrl, $iWait) ; Store @error after _IENavigate() so that it can be returned. Local $iError = @error ; IE9 sets focus to the URL bar when an about: URI is displayed (such as about:blank). This can cause ; _IEAction(..., "focus") to work incorrectly. It will give focus to the element (as shown by the elements's ; appearance changing but) the input caret will not move. The work-around for this "helpful" behavior is ; to explicitly give focus to the document. We should only do this for about: URIs and on successful ; navigate. If Not $iError And StringLeft($sUrl, 6) = "about:" Then Local $oDocument = $oObject.document _IEAction($oDocument, "focus") EndIf Return SetError($iError, 0, $oObject) EndFunc ;==>_IECreate ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IECreateEmbedded() Local $oObject = ObjCreate("Shell.Explorer.2") If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IECreateEmbedded", "", "WebBrowser Object Creation Failed") Return SetError($_IESTATUS_GeneralError, 0, 0) EndIf ; Return SetError($_IESTATUS_Success, 0, $oObject) EndFunc ;==>_IECreateEmbedded ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IENavigate(ByRef $oObject, $sUrl, $iWait = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; $oObject.navigate($sUrl) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf If $iWait Then _IELoadWait($oObject) Return SetError(@error, 0, -1) EndIf Return SetError($_IESTATUS_Success, 0, -1) EndFunc ;==>_IENavigate ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEAttach($sString, $sMode = "title", $iInstance = 1) $sMode = StringLower($sMode) $iInstance = Int($iInstance) If $iInstance < 1 Then __IEConsoleWriteError("Error", "_IEAttach", "$_IESTATUS_InvalidValue", "$iInstance < 1") Return SetError($_IESTATUS_InvalidValue, 3, 0) EndIf If $sMode = "embedded" Or $sMode = "dialogbox" Then Local $iWinTitleMatchMode = Opt("WinTitleMatchMode", $OPT_MATCHANY) If $sMode = "dialogbox" And $iInstance > 1 Then If IsHWnd($sString) Then $iInstance = 1 __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_GeneralError", "$iInstance > 1 invalid with HWnd and DialogBox. Setting to 1.") Else Local $aWinlist = WinList($sString, "") If $iInstance <= $aWinlist[0][0] Then $sString = $aWinlist[$iInstance][1] $iInstance = 1 Else __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_NoMatch") Opt("WinTitleMatchMode", $iWinTitleMatchMode) Return SetError($_IESTATUS_NoMatch, 1, 0) EndIf EndIf EndIf Local $hControl = ControlGetHandle($sString, "", "[CLASS:Internet Explorer_Server; INSTANCE:" & $iInstance & "]") Local $oResult = __IEControlGetObjFromHWND($hControl) Opt("WinTitleMatchMode", $iWinTitleMatchMode) If IsObj($oResult) Then Return SetError($_IESTATUS_Success, 0, $oResult) Else __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 1, 0) EndIf EndIf Local $oShell = ObjCreate("Shell.Application") Local $oShellWindows = $oShell.Windows(); collection of all ShellWindows (IE and File Explorer) Local $iTmp = 1 Local $iNotifyStatus, $bIsBrowser, $sTmp Local $bStatus For $oWindow In $oShellWindows ;------------------------------------------------------------------------------------------ ; Check to verify that the window object is a valid browser, if not, skip it ; ; Setup internal error handler to Trap COM errors, turn off error notification, ; check object property validity, set a flag and reset error handler and notification ; $bIsBrowser = True ; Trap COM errors and turn off error notification $bStatus = __IEInternalErrorHandlerRegister() If Not $bStatus Then __IEConsoleWriteError("Warning", "_IEAttach", _ "Cannot register internal error handler, cannot trap COM errors", _ "Use _IEErrorHandlerRegister() to register a user error handler") ; Turn off error notification for internal processing $iNotifyStatus = _IEErrorNotify() ; save current error notify status _IEErrorNotify(False) ; Check conditions to verify that the object is a browser If $bIsBrowser Then $sTmp = $oWindow.type ; Is .type a valid property? If @error Then $bIsBrowser = False EndIf If $bIsBrowser Then $sTmp = $oWindow.document.title ; Does object have a .document and .title property? If @error Then $bIsBrowser = False EndIf ; restore error notify _IEErrorNotify($iNotifyStatus) ; restore notification status __IEInternalErrorHandlerDeRegister() ;------------------------------------------------------------------------------------------ If $bIsBrowser Then Switch $sMode Case "title" If StringInStr($oWindow.document.title, $sString) > 0 Then If $iInstance = $iTmp Then Return SetError($_IESTATUS_Success, 0, $oWindow) Else $iTmp += 1 EndIf EndIf Case "instance" If $iInstance = $iTmp Then Return SetError($_IESTATUS_Success, 0, $oWindow) Else $iTmp += 1 EndIf Case "windowtitle" Local $bFound = False $sTmp = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\", "Window Title") If Not @error Then If StringInStr($oWindow.document.title & " - " & $sTmp, $sString) Then $bFound = True Else If StringInStr($oWindow.document.title & " - Microsoft Internet Explorer", $sString) Then $bFound = True If StringInStr($oWindow.document.title & " - Windows Internet Explorer", $sString) Then $bFound = True EndIf If $bFound Then If $iInstance = $iTmp Then Return SetError($_IESTATUS_Success, 0, $oWindow) Else $iTmp += 1 EndIf EndIf Case "url" If StringInStr($oWindow.LocationURL, $sString) > 0 Then If $iInstance = $iTmp Then Return SetError($_IESTATUS_Success, 0, $oWindow) Else $iTmp += 1 EndIf EndIf Case "text" If StringInStr($oWindow.document.body.innerText, $sString) > 0 Then If $iInstance = $iTmp Then Return SetError($_IESTATUS_Success, 0, $oWindow) Else $iTmp += 1 EndIf EndIf Case "html" If StringInStr($oWindow.document.body.innerHTML, $sString) > 0 Then If $iInstance = $iTmp Then Return SetError($_IESTATUS_Success, 0, $oWindow) Else $iTmp += 1 EndIf EndIf Case "hwnd" If $iInstance > 1 Then $iInstance = 1 __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_GeneralError", "$iInstance > 1 invalid with HWnd. Setting to 1.") EndIf If _IEPropertyGet($oWindow, "hwnd") = $sString Then Return SetError($_IESTATUS_Success, 0, $oWindow) EndIf Case Else ; Invalid Mode __IEConsoleWriteError("Error", "_IEAttach", "$_IESTATUS_InvalidValue", "Invalid Mode Specified") Return SetError($_IESTATUS_InvalidValue, 2, 0) EndSwitch EndIf Next __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 1, 0) EndFunc ;==>_IEAttach ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; Modified ......: jpm ; =============================================================================================================================== Func _IELoadWait(ByRef $oObject, $iDelay = 0, $iTimeout = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IELoadWait", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IELoadWait", "$_IESTATUS_InvalidObjectType", ObjName($oObject)) Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Local $oTemp, $bAbort = False, $iErrorStatusCode = $_IESTATUS_Success ; Setup internal error handler to Trap COM errors, turn off error notification Local $bStatus = __IEInternalErrorHandlerRegister() If Not $bStatus Then __IEConsoleWriteError("Warning", "_IELoadWait", _ "Cannot register internal error handler, cannot trap COM errors", _ "Use _IEErrorHandlerRegister() to register a user error handler") Local $iNotifyStatus = _IEErrorNotify() ; save current error notify status _IEErrorNotify(False) Sleep($iDelay) ; Local $iError Local $hIELoadWaitTimer = TimerInit() If $iTimeout = -1 Then $iTimeout = $__g_iIELoadWaitTimeout Select Case __IEIsObjType($oObject, "browser", False); Internet Explorer While Not (String($oObject.readyState) = "complete" Or $oObject.readyState = 4 Or $bAbort) ; Trap unrecoverable COM errors If @error Then $iError = @error If __IEComErrorUnrecoverable($iError) Then $iErrorStatusCode = __IEComErrorUnrecoverable($iError) $bAbort = True EndIf ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout $bAbort = True EndIf Sleep(100) WEnd While Not (String($oObject.document.readyState) = "complete" Or $oObject.document.readyState = 4 Or $bAbort) ; Trap unrecoverable COM errors If @error Then $iError = @error If __IEComErrorUnrecoverable($iError) Then $iErrorStatusCode = __IEComErrorUnrecoverable($iError) $bAbort = True EndIf ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout $bAbort = True EndIf Sleep(100) WEnd Case __IEIsObjType($oObject, "window", False) ; Window, Frame, iFrame While Not (String($oObject.document.readyState) = "complete" Or $oObject.document.readyState = 4 Or $bAbort) ; Trap unrecoverable COM errors If @error Then $iError = @error If __IEComErrorUnrecoverable($iError) Then $iErrorStatusCode = __IEComErrorUnrecoverable($iError) $bAbort = True EndIf ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout $bAbort = True EndIf Sleep(100) WEnd While Not (String($oObject.top.document.readyState) = "complete" Or $oObject.top.document.readyState = 4 Or $bAbort) ; Trap unrecoverable COM errors If @error Then $iError = @error If __IEComErrorUnrecoverable($iError) Then $iErrorStatusCode = __IEComErrorUnrecoverable($iError) $bAbort = True EndIf ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout $bAbort = True EndIf Sleep(100) WEnd Case __IEIsObjType($oObject, "document", False) ; Document $oTemp = $oObject.parentWindow While Not (String($oTemp.document.readyState) = "complete" Or $oTemp.document.readyState = 4 Or $bAbort) ; Trap unrecoverable COM errors If @error Then $iError = @error If __IEComErrorUnrecoverable($iError) Then $iErrorStatusCode = __IEComErrorUnrecoverable($iError) $bAbort = True EndIf ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout $bAbort = True EndIf Sleep(100) WEnd While Not (String($oTemp.top.document.readyState) = "complete" Or $oTemp.top.document.readyState = 4 Or $bAbort) ; Trap unrecoverable COM errors If @error Then $iError = @error If __IEComErrorUnrecoverable($iError) Then $iErrorStatusCode = __IEComErrorUnrecoverable($iError) $bAbort = True EndIf ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout $bAbort = True EndIf Sleep(100) WEnd Case Else ; this should work with any other DOM object $oTemp = $oObject.document.parentWindow While Not (String($oTemp.document.readyState) = "complete" Or $oTemp.document.readyState = 4 Or $bAbort) ; Trap unrecoverable COM errors If @error Then $iError = @error If __IEComErrorUnrecoverable($iError) Then $iErrorStatusCode = __IEComErrorUnrecoverable($iError) $bAbort = True EndIf ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout $bAbort = True EndIf Sleep(100) WEnd While Not (String($oTemp.top.document.readyState) = "complete" Or $oObject.top.document.readyState = 4 Or $bAbort) ; Trap unrecoverable COM errors If @error Then $iError = @error If __IEComErrorUnrecoverable($iError) Then $iErrorStatusCode = __IEComErrorUnrecoverable($iError) $bAbort = True EndIf ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout $bAbort = True EndIf Sleep(100) WEnd EndSelect ; restore error notify _IEErrorNotify($iNotifyStatus) ; restore notification status __IEInternalErrorHandlerDeRegister() Switch $iErrorStatusCode Case $_IESTATUS_Success Return SetError($_IESTATUS_Success, 0, 1) Case $_IESTATUS_LoadWaitTimeout __IEConsoleWriteError("Warning", "_IELoadWait", "$_IESTATUS_LoadWaitTimeout") Return SetError($_IESTATUS_LoadWaitTimeout, 3, 0) Case $_IESTATUS_AccessIsDenied __IEConsoleWriteError("Warning", "_IELoadWait", "$_IESTATUS_AccessIsDenied", _ "Cannot verify readyState. Likely casue: cross-domain scripting security restriction. (" & $iError & ")") Return SetError($_IESTATUS_AccessIsDenied, 0, 0) Case $_IESTATUS_ClientDisconnected __IEConsoleWriteError("Error", "_IELoadWait", "$_IESTATUS_ClientDisconnected", _ $iError & ", Browser has been deleted prior to operation.") Return SetError($_IESTATUS_ClientDisconnected, 0, 0) Case Else __IEConsoleWriteError("Error", "_IELoadWait", "$_IESTATUS_GeneralError", "Invalid Error Status - Notify IE.au3 developer") Return SetError($_IESTATUS_GeneralError, 0, 0) EndSwitch EndFunc ;==>_IELoadWait ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IELoadWaitTimeout($iTimeout = -1) If $iTimeout = -1 Then Return SetError($_IESTATUS_Success, 0, $__g_iIELoadWaitTimeout) Else $__g_iIELoadWaitTimeout = $iTimeout Return SetError($_IESTATUS_Success, 0, 1) EndIf EndFunc ;==>_IELoadWaitTimeout #EndRegion Core functions #Region Frame Functions ; Security Note on Frame functions: ; Note that security restriction in Internet Explorer related to cross-site scripting ; between frames can cause serious problems with the frame functions. Functions that ; work connected to one site will fail when connected to another depending on the sites ; referenced in the frames. In general, if all the referenced pages are on the same ; webserver these functions should work as described; if not, unexpected COM failures ; can occur. ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEIsFrameSet(ByRef $oObject) ; Note: this is more reliable test for a FrameSet than checking the ; number of frames (document.frames.length) because iFrames embedded on a normal ; page are included in the frame collection even though it is not a FrameSet If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEIsFrameSet", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If String($oObject.document.body.tagName) = "frameset" Then Return SetError($_IESTATUS_Success, 0, 1) Else If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEIsFrameSet", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf Return SetError($_IESTATUS_Success, 0, 0) EndIf EndFunc ;==>_IEIsFrameSet ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFrameGetCollection(ByRef $oObject, $iIndex = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFrameGetCollection", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; $iIndex = Number($iIndex) Select Case $iIndex = -1 Return SetError($_IESTATUS_Success, $oObject.document.parentwindow.frames.length, _ $oObject.document.parentwindow.frames) Case $iIndex > -1 And $iIndex < $oObject.document.parentwindow.frames.length Return SetError($_IESTATUS_Success, $oObject.document.parentwindow.frames.length, _ $oObject.document.parentwindow.frames.item($iIndex)) Case $iIndex < -1 __IEConsoleWriteError("Error", "_IEFrameGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1") Return SetError($_IESTATUS_InvalidValue, 2, 0) Case Else __IEConsoleWriteError("Warning", "_IEFrameGetCollection", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 2, 0) EndSelect EndFunc ;==>_IEFrameGetCollection ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFrameGetObjByName(ByRef $oObject, $sName) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFrameGetObjByName", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; Local $oTemp, $oFrames If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IEFrameGetObjByName", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If __IEIsObjType($oObject, "document") Then $oTemp = $oObject.parentWindow Else $oTemp = $oObject.document.parentWindow EndIf If _IEIsFrameSet($oTemp) Then $oFrames = _IETagNameGetCollection($oTemp, "frame") Else $oFrames = _IETagNameGetCollection($oTemp, "iframe") EndIf If $oFrames.length Then For $oFrame In $oFrames If String($oFrame.name) = $sName Then Return SetError($_IESTATUS_Success, 0, $oTemp.frames($sName)) Next __IEConsoleWriteError("Warning", "_IEFrameGetObjByName", "$_IESTATUS_NoMatch", "No frames matching name") Return SetError($_IESTATUS_NoMatch, 2, 0) Else __IEConsoleWriteError("Warning", "_IEFrameGetObjByName", "$_IESTATUS_NoMatch", "No Frames found") Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf EndFunc ;==>_IEFrameGetObjByName #EndRegion Frame Functions #Region Link functions ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IELinkClickByText(ByRef $oObject, $sLinkText, $iIndex = 0, $iWait = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IELinkClickByText", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; Local $iFound = 0, $sModeLinktext, $oLinks = $oObject.document.links $iIndex = Number($iIndex) For $oLink In $oLinks $sModeLinktext = String($oLink.outerText) If $sModeLinktext = $sLinkText Then If ($iFound = $iIndex) Then $oLink.click() If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IELinkClickByText", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf If $iWait Then _IELoadWait($oObject) Return SetError(@error, 0, -1) EndIf Return SetError($_IESTATUS_Success, 0, -1) EndIf $iFound = $iFound + 1 EndIf Next __IEConsoleWriteError("Warning", "_IELinkClickByText", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both EndFunc ;==>_IELinkClickByText ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IELinkClickByIndex(ByRef $oObject, $iIndex, $iWait = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IELinkClickByIndex", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; Local $oLinks = $oObject.document.links, $oLink $iIndex = Number($iIndex) If ($iIndex >= 0) And ($iIndex <= $oLinks.length - 1) Then $oLink = $oLinks($iIndex) $oLink.click() If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IELinkClickByIndex", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf If $iWait Then _IELoadWait($oObject) Return SetError(@error, 0, -1) EndIf Return SetError($_IESTATUS_Success, 0, -1) Else __IEConsoleWriteError("Warning", "_IELinkClickByIndex", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf EndFunc ;==>_IELinkClickByIndex ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IELinkGetCollection(ByRef $oObject, $iIndex = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IELinkGetCollection", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; $iIndex = Number($iIndex) Select Case $iIndex = -1 Return SetError($_IESTATUS_Success, $oObject.document.links.length, _ $oObject.document.links) Case $iIndex > -1 And $iIndex < $oObject.document.links.length Return SetError($_IESTATUS_Success, $oObject.document.links.length, _ $oObject.document.links.item($iIndex)) Case $iIndex < -1 __IEConsoleWriteError("Error", "_IELinkGetCollection", "$_IESTATUS_InvalidValue") Return SetError($_IESTATUS_InvalidValue, 2, 0) Case Else __IEConsoleWriteError("Warning", "_IELinkGetCollection", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 2, 0) EndSelect EndFunc ;==>_IELinkGetCollection #EndRegion Link functions #Region Image functions ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; Modified ......: jpm ; =============================================================================================================================== Func _IEImgClick(ByRef $oObject, $sLinkText, $sMode = "src", $iIndex = 0, $iWait = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEImgClick", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; Local $sModeLinktext, $iFound = 0, $oImgs = $oObject.document.images $sMode = StringLower($sMode) $iIndex = Number($iIndex) For $oImg In $oImgs Select Case $sMode = "alt" $sModeLinktext = $oImg.alt Case $sMode = "name" $sModeLinktext = $oImg.name If Not IsString($sModeLinktext) Then $sModeLinktext = $oImg.id ; html5 support Case $sMode = "id" $sModeLinktext = $oImg.id Case $sMode = "src" $sModeLinktext = $oImg.src Case Else __IEConsoleWriteError("Error", "_IEImgClick", "$_IESTATUS_InvalidValue", "Invalid mode: " & $sMode) Return SetError($_IESTATUS_InvalidValue, 3, 0) EndSelect If StringInStr($sModeLinktext, $sLinkText) Then If ($iFound = $iIndex) Then $oImg.click() If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEImgClick", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf If $iWait Then _IELoadWait($oObject) Return SetError(@error, 0, -1) EndIf Return SetError($_IESTATUS_Success, 0, -1) EndIf $iFound = $iFound + 1 EndIf Next __IEConsoleWriteError("Warning", "_IEImgClick", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 4 or both EndFunc ;==>_IEImgClick ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEImgGetCollection(ByRef $oObject, $iIndex = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEImgGetCollection", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; Local $oTemp = _IEDocGetObj($oObject) $iIndex = Number($iIndex) Select Case $iIndex = -1 Return SetError($_IESTATUS_Success, $oTemp.images.length, $oTemp.images) Case $iIndex > -1 And $iIndex < $oTemp.images.length Return SetError($_IESTATUS_Success, $oTemp.images.length, $oTemp.images.item($iIndex)) Case $iIndex < -1 __IEConsoleWriteError("Error", "_IEImgGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1") Return SetError($_IESTATUS_InvalidValue, 2, 0) Case Else __IEConsoleWriteError("Warning", "_IEImgGetCollection", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 1, 0) EndSelect EndFunc ;==>_IEImgGetCollection #EndRegion Image functions #Region Form functions ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormGetCollection(ByRef $oObject, $iIndex = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormGetCollection", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; Local $oTemp = _IEDocGetObj($oObject) $iIndex = Number($iIndex) Select Case $iIndex = -1 Return SetError($_IESTATUS_Success, $oTemp.forms.length, $oTemp.forms) Case $iIndex > -1 And $iIndex < $oTemp.forms.length Return SetError($_IESTATUS_Success, $oTemp.forms.length, $oTemp.forms.item($iIndex)) Case $iIndex < -1 __IEConsoleWriteError("Error", "_IEFormGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1") Return SetError($_IESTATUS_InvalidValue, 2, 0) Case Else __IEConsoleWriteError("Warning", "_IEFormGetCollection", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 1, 0) EndSelect EndFunc ;==>_IEFormGetCollection ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormGetObjByName(ByRef $oObject, $sName, $iIndex = 0) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormGetObjByName", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; ;----- Determine valid collection length Local $iLength = 0 Local $oCol = $oObject.document.forms.item($sName) If IsObj($oCol) Then If __IEIsObjType($oCol, "elementcollection") Then $iLength = $oCol.length Else $iLength = 1 EndIf EndIf ;----- $iIndex = Number($iIndex) If $iIndex = -1 Then Return SetError($_IESTATUS_Success, $iLength, $oObject.document.forms.item($sName)) Else If IsObj($oObject.document.forms.item($sName, $iIndex)) Then Return SetError($_IESTATUS_Success, $iLength, $oObject.document.forms.item($sName, $iIndex)) Else __IEConsoleWriteError("Warning", "_IEFormGetObjByName", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both EndIf EndIf EndFunc ;==>_IEFormGetObjByName ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormElementGetCollection(ByRef $oObject, $iIndex = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormElementGetCollection", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "form") Then __IEConsoleWriteError("Error", "_IEFormElementGetCollection", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; $iIndex = Number($iIndex) Select Case $iIndex = -1 Return SetError($_IESTATUS_Success, $oObject.elements.length, $oObject.elements) Case $iIndex > -1 And $iIndex < $oObject.elements.length Return SetError($_IESTATUS_Success, $oObject.elements.length, $oObject.elements.item($iIndex)) Case $iIndex < -1 __IEConsoleWriteError("Error", "_IEFormElementGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1") Return SetError($_IESTATUS_InvalidValue, 2, 0) Case Else Return SetError($_IESTATUS_NoMatch, 1, 0) EndSelect EndFunc ;==>_IEFormElementGetCollection ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormElementGetObjByName(ByRef $oObject, $sName, $iIndex = 0) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormElementGetObjByName", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "form") Then __IEConsoleWriteError("Error", "_IEFormElementGetObjByName", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; ;----- Determine valid collection length Local $iLength = 0 Local $oCol = $oObject.elements.item($sName) If IsObj($oCol) Then If __IEIsObjType($oCol, "elementcollection") Then $iLength = $oCol.length Else $iLength = 1 EndIf EndIf ;----- $iIndex = Number($iIndex) If $iIndex = -1 Then Return SetError($_IESTATUS_Success, $iLength, $oObject.elements.item($sName)) Else If IsObj($oObject.elements.item($sName, $iIndex)) Then Return SetError($_IESTATUS_Success, $iLength, $oObject.elements.item($sName, $iIndex)) Else __IEConsoleWriteError("Warning", "_IEFormElementGetObjByName", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both EndIf EndIf EndFunc ;==>_IEFormElementGetObjByName ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormElementGetValue(ByRef $oObject) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormElementGetValue", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "forminputelement") Then __IEConsoleWriteError("Error", "_IEFormElementGetValue", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; Local $sReturn = String($oObject.value) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEFormElementGetValue", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf SetError($_IESTATUS_Success) Return $sReturn EndFunc ;==>_IEFormElementGetValue ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormElementSetValue(ByRef $oObject, $sNewValue, $iFireEvent = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormElementSetValue", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "forminputelement") Then __IEConsoleWriteError("Error", "_IEFormElementSetValue", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; If String($oObject.type) = "file" Then __IEConsoleWriteError("Error", "_IEFormElementSetValue", "$_IESTATUS_InvalidObjectType", "Browser security prevents SetValue of TYPE=FILE") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; $oObject.value = $sNewValue If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEFormElementSetValue", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf If $iFireEvent Then $oObject.fireEvent("OnChange") $oObject.fireEvent("OnClick") EndIf Return SetError($_IESTATUS_Success, 0, 1) EndFunc ;==>_IEFormElementSetValue ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormElementOptionSelect(ByRef $oObject, $sString, $iSelect = 1, $sMode = "byValue", $iFireEvent = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "formselectelement") Then __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; Local $oItem, $oItems = $oObject.options, $iNumItems = $oObject.options.length, $bIsMultiple = $oObject.multiple Switch $sMode Case "byValue" For $oItem In $oItems If $oItem.value = $sString Then Switch $iSelect Case -1 Return SetError($_IESTATUS_Success, 0, $oItem.selected) Case 0 If Not $bIsMultiple Then __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", _ "$iSelect=0 only valid for type=select multiple") SetError($_IESTATUS_InvalidValue, 3) EndIf If $oItem.selected Then $oItem.selected = False If $iFireEvent Then $oObject.fireEvent("onChange") $oObject.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case 1 If Not $oItem.selected Then $oItem.selected = True If $iFireEvent Then $oObject.fireEvent("onChange") $oObject.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case Else __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid $iSelect value") Return SetError($_IESTATUS_InvalidValue, 3, 0) EndSwitch __IEConsoleWriteError("Warning", "_IEFormElementOptionSelect", "$_IESTATUS_NoMatch", "Value not matched") Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf Next Case "byText" For $oItem In $oItems If String($oItem.text) = $sString Then Switch $iSelect Case -1 Return SetError($_IESTATUS_Success, 0, $oItem.selected) Case 0 If Not $bIsMultiple Then __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", _ "$iSelect=0 only valid for type=select multiple") SetError($_IESTATUS_InvalidValue, 3) EndIf If $oItem.selected Then $oItem.selected = False If $iFireEvent Then $oObject.fireEvent("onChange") $oObject.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case 1 If Not $oItem.selected Then $oItem.selected = True If $iFireEvent Then $oObject.fireEvent("onChange") $oObject.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case Else __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid $iSelect value") Return SetError($_IESTATUS_InvalidValue, 3, 0) EndSwitch __IEConsoleWriteError("Warning", "_IEFormElementOptionSelect", "$_IESTATUS_NoMatch", "Text not matched") Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf Next Case "byIndex" Local $iIndex = Number($sString) If $iIndex < 0 Or $iIndex >= $iNumItems Then __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid index value, " & $iIndex) Return SetError($_IESTATUS_InvalidValue, 2, 0) EndIf $oItem = $oItems.item($iIndex) Switch $iSelect Case -1 Return SetError($_IESTATUS_Success, 0, $oItems.item($iIndex).selected) Case 0 If Not $bIsMultiple Then __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", _ "$iSelect=0 only valid for type=select multiple") SetError($_IESTATUS_InvalidValue, 3) EndIf If $oItem.selected Then $oItems.item($iIndex).selected = False If $iFireEvent Then $oObject.fireEvent("onChange") $oObject.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case 1 If Not $oItem.selected Then $oItems.item($iIndex).selected = True If $iFireEvent Then $oObject.fireEvent("onChange") $oObject.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case Else __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid $iSelect value") Return SetError($_IESTATUS_InvalidValue, 3, 0) EndSwitch Case Else __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid Mode") Return SetError($_IESTATUS_InvalidValue, 4, 0) EndSwitch EndFunc ;==>_IEFormElementOptionSelect ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormElementCheckBoxSelect(ByRef $oObject, $sString, $sName = "", $iSelect = 1, $sMode = "byValue", $iFireEvent = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormElementCheckBoxSelect", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "form") Then __IEConsoleWriteError("Error", "_IEFormElementCheckBoxSelect", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; $sString = String($sString) $sName = String($sName) Local $oItems If $sName = "" Then $oItems = _IETagNameGetCollection($oObject, "input") Else $oItems = Execute("$oObject.elements('" & $sName & "')") EndIf If Not IsObj($oItems) Then __IEConsoleWriteError("Warning", "_IEFormElementCheckBoxSelect", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 3, 0) EndIf Local $oItem, $bFound = False Switch $sMode Case "byValue" If __IEIsObjType($oItems, "forminputelement") Then $oItem = $oItems If String($oItem.type) = "checkbox" And String($oItem.value) = $sString Then $bFound = True Else For $oItem In $oItems If String($oItem.type) = "checkbox" And String($oItem.value) = $sString Then $bFound = True ExitLoop EndIf Next EndIf Case "byIndex" If __IEIsObjType($oItems, "forminputelement") Then $oItem = $oItems If String($oItem.type) = "checkbox" And Number($sString) = 0 Then $bFound = True Else Local $iCount = 0 For $oItem In $oItems If String($oItem.type) = "checkbox" And Number($sString) = $iCount Then $bFound = True ExitLoop Else If String($oItem.type) = "checkbox" Then $iCount += 1 EndIf Next EndIf Case Else __IEConsoleWriteError("Error", "_IEFormElementCheckBoxSelect", "$_IESTATUS_InvalidValue", "Invalid Mode") Return SetError($_IESTATUS_InvalidValue, 5, 0) EndSwitch If Not $bFound Then __IEConsoleWriteError("Warning", "_IEFormElementCheckBoxSelect", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf Switch $iSelect Case -1 Return SetError($_IESTATUS_Success, 0, $oItem.checked) Case 0 If $oItem.checked Then $oItem.checked = False If $iFireEvent Then $oItem.fireEvent("onChange") $oItem.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case 1 If Not $oItem.checked Then $oItem.checked = True If $iFireEvent Then $oItem.fireEvent("onChange") $oItem.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case Else __IEConsoleWriteError("Error", "_IEFormElementCheckBoxSelect", "$_IESTATUS_InvalidValue", "Invalid $iSelect value") Return SetError($_IESTATUS_InvalidValue, 3, 0) EndSwitch EndFunc ;==>_IEFormElementCheckBoxSelect ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormElementRadioSelect(ByRef $oObject, $sString, $sName, $iSelect = 1, $sMode = "byValue", $iFireEvent = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormElementRadioSelect", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "form") Then __IEConsoleWriteError("Error", "_IEFormElementRadioSelect", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; $sString = String($sString) $sName = String($sName) Local $oItems = Execute("$oObject.elements('" & $sName & "')") If Not IsObj($oItems) Then __IEConsoleWriteError("Warning", "_IEFormElementRadioSelect", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 3, 0) EndIf Local $oItem, $bFound = False Switch $sMode Case "byValue" If __IEIsObjType($oItems, "forminputelement") Then $oItem = $oItems If String($oItem.type) = "radio" And String($oItem.value) = $sString Then $bFound = True Else For $oItem In $oItems If String($oItem.type) = "radio" And String($oItem.value) = $sString Then $bFound = True ExitLoop EndIf Next EndIf Case "byIndex" If __IEIsObjType($oItems, "forminputelement") Then $oItem = $oItems If String($oItem.type) = "radio" And Number($sString) = 0 Then $bFound = True Else Local $iCount = 0 For $oItem In $oItems If String($oItem.type) = "radio" And Number($sString) = $iCount Then $bFound = True ExitLoop Else $iCount += 1 EndIf Next EndIf Case Else __IEConsoleWriteError("Error", "_IEFormElementRadioSelect", "$_IESTATUS_InvalidValue", "Invalid Mode") Return SetError($_IESTATUS_InvalidValue, 5, 0) EndSwitch If Not $bFound Then __IEConsoleWriteError("Warning", "_IEFormElementRadioSelect", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf Switch $iSelect Case -1 Return SetError($_IESTATUS_Success, 0, $oItem.checked) Case 0 If $oItem.checked Then $oItem.checked = False If $iFireEvent Then $oItem.fireEvent("onChange") $oItem.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case 1 If Not $oItem.checked Then $oItem.checked = True If $iFireEvent Then $oItem.fireEvent("onChange") $oItem.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case Else __IEConsoleWriteError("Error", "_IEFormElementRadioSelect", "$_IESTATUS_InvalidValue", "$iSelect value invalid") Return SetError($_IESTATUS_InvalidValue, 4, 0) EndSwitch EndFunc ;==>_IEFormElementRadioSelect ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; Modified ......: jpm ; =============================================================================================================================== Func _IEFormImageClick(ByRef $oObject, $sLinkText, $sMode = "src", $iIndex = 0, $iWait = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormImageClick", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; Local $sModeLinktext, $iFound = 0 Local $oTemp = _IEDocGetObj($oObject) Local $oImgs = _IETagNameGetCollection($oTemp, "input") $sMode = StringLower($sMode) $iIndex = Number($iIndex) For $oImg In $oImgs If String($oImg.type) = "image" Then Select Case $sMode = "alt" $sModeLinktext = $oImg.alt Case $sMode = "name" $sModeLinktext = $oImg.name If Not IsString($sModeLinktext) Then $sModeLinktext = $oImg.id ; html5 support Case $sMode = "id" $sModeLinktext = $oImg.id Case $sMode = "src" $sModeLinktext = $oImg.src Case Else __IEConsoleWriteError("Error", "_IEFormImageClick", "$_IESTATUS_InvalidValue", "Invalid mode: " & $sMode) Return SetError($_IESTATUS_InvalidValue, 3, 0) EndSelect If StringInStr($sModeLinktext, $sLinkText) Then If ($iFound = $iIndex) Then $oImg.click() If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEFormImageClick", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf If $iWait Then _IELoadWait($oObject) Return SetError(@error, 0, -1) EndIf Return SetError($_IESTATUS_Success, 0, -1) EndIf $iFound = $iFound + 1 EndIf EndIf Next __IEConsoleWriteError("Warning", "_IEFormImageClick", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 2, 0) EndFunc ;==>_IEFormImageClick ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormSubmit(ByRef $oObject, $iWait = 1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormSubmit", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "form") Then __IEConsoleWriteError("Error", "_IEFormSubmit", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; Local $oWindow = $oObject.document.parentWindow $oObject.submit() If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEFormSubmit", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf If $iWait Then _IELoadWait($oWindow) Return SetError(@error, 0, -1) EndIf Return SetError($_IESTATUS_Success, 0, -1) EndFunc ;==>_IEFormSubmit ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEFormReset(ByRef $oObject) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEFormReset", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "form") Then __IEConsoleWriteError("Error", "_IEFormReset", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; $oObject.reset() If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEFormReset", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf Return SetError($_IESTATUS_Success, 0, 1) EndFunc ;==>_IEFormReset #EndRegion Form functions #Region Table functions ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IETableGetCollection(ByRef $oObject, $iIndex = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IETableGetCollection", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; $iIndex = Number($iIndex) Select Case $iIndex = -1 Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByTagName("table").length, _ $oObject.document.GetElementsByTagName("table")) Case $iIndex > -1 And $iIndex < $oObject.document.GetElementsByTagName("table").length Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByTagName("table").length, _ $oObject.document.GetElementsByTagName("table").item($iIndex)) Case $iIndex < -1 __IEConsoleWriteError("Error", "_IETableGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1") Return SetError($_IESTATUS_InvalidValue, 2, 0) Case Else __IEConsoleWriteError("Warning", "_IETableGetCollection", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 1, 0) EndSelect EndFunc ;==>_IETableGetCollection ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IETableWriteToArray(ByRef $oObject, $bTranspose = False) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "table") Then __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; Local $iCols = 0, $oTds, $iCol Local $oTrs = $oObject.rows For $oTr In $oTrs $oTds = $oTr.cells $iCol = 0 For $oTd In $oTds $iCol = $iCol + $oTd.colSpan Next If $iCol > $iCols Then $iCols = $iCol Next Local $iRows = $oTrs.length Local $aTableCells[$iCols][$iRows] Local $iRow = 0 For $oTr In $oTrs $oTds = $oTr.cells $iCol = 0 For $oTd In $oTds $aTableCells[$iCol][$iRow] = String($oTd.innerText) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf $iCol = $iCol + $oTd.colSpan Next $iRow = $iRow + 1 Next If $bTranspose Then Local $iD1 = UBound($aTableCells, $UBOUND_ROWS), $iD2 = UBound($aTableCells, $UBOUND_COLUMNS), $aTmp[$iD2][$iD1] For $i = 0 To $iD2 - 1 For $j = 0 To $iD1 - 1 $aTmp[$i][$j] = $aTableCells[$j][$i] Next Next $aTableCells = $aTmp EndIf Return SetError($_IESTATUS_Success, 0, $aTableCells) EndFunc ;==>_IETableWriteToArray #EndRegion Table functions #Region Read/Write functions ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEBodyReadHTML(ByRef $oObject) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEBodyReadHTML", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; Return SetError($_IESTATUS_Success, 0, $oObject.document.body.innerHTML) EndFunc ;==>_IEBodyReadHTML ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEBodyReadText(ByRef $oObject) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEBodyReadText", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IEBodyReadText", "$_IESTATUS_InvalidObjectType", "Expected document element") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; Return SetError($_IESTATUS_Success, 0, $oObject.document.body.innerText) EndFunc ;==>_IEBodyReadText ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEBodyWriteHTML(ByRef $oObject, $sHTML) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEBodyWriteHTML", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IEBodyWriteHTML", "$_IESTATUS_InvalidObjectType", "Expected document element") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; $oObject.document.body.innerHTML = $sHTML If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEBodyWriteHTML", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf Local $oTemp = $oObject.document _IELoadWait($oTemp) Return SetError(@error, 0, -1) EndFunc ;==>_IEBodyWriteHTML ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEDocReadHTML(ByRef $oObject) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEDocReadHTML", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IEDocReadHTML", "$_IESTATUS_InvalidObjectType", "Expected document element") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; Return SetError($_IESTATUS_Success, 0, $oObject.document.documentElement.outerHTML) EndFunc ;==>_IEDocReadHTML ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEDocWriteHTML(ByRef $oObject, $sHTML) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEDocWriteHTML", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IEDocWriteHTML", "$_IESTATUS_InvalidObjectType", "Expected document element") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; $oObject.document.Write($sHTML) $oObject.document.close() Local $oTemp = $oObject.document If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEDocWriteHTML", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf _IELoadWait($oTemp) Return SetError(@error, 0, -1) EndFunc ;==>_IEDocWriteHTML ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEDocInsertText(ByRef $oObject, $sString, $sWhere = "beforeend") If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEDocInsertText", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf If Not __IEIsObjType($oObject, "browserdom") Or __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then __IEConsoleWriteError("Error", "_IEDocInsertText", "$_IESTATUS_InvalidObjectType", "Expected document element") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $sWhere = StringLower($sWhere) Select Case $sWhere = "beforebegin" $oObject.insertAdjacentText($sWhere, $sString) Case $sWhere = "afterbegin" $oObject.insertAdjacentText($sWhere, $sString) Case $sWhere = "beforeend" $oObject.insertAdjacentText($sWhere, $sString) Case $sWhere = "afterend" $oObject.insertAdjacentText($sWhere, $sString) Case Else ; Unsupported Where __IEConsoleWriteError("Error", "_IEDocInsertText", "$_IESTATUS_InvalidValue", "Invalid where value") Return SetError($_IESTATUS_InvalidValue, 3, 0) EndSelect If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEDocInsertText", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf Return SetError($_IESTATUS_Success, 0, 1) EndFunc ;==>_IEDocInsertText ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEDocInsertHTML(ByRef $oObject, $sString, $sWhere = "beforeend") If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEDocInsertHTML", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf If Not __IEIsObjType($oObject, "browserdom") Or __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then __IEConsoleWriteError("Error", "_IEDocInsertHTML", "$_IESTATUS_InvalidObjectType", "Expected document element") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $sWhere = StringLower($sWhere) Select Case $sWhere = "beforebegin" $oObject.insertAdjacentHTML($sWhere, $sString) Case $sWhere = "afterbegin" $oObject.insertAdjacentHTML($sWhere, $sString) Case $sWhere = "beforeend" $oObject.insertAdjacentHTML($sWhere, $sString) Case $sWhere = "afterend" $oObject.insertAdjacentHTML($sWhere, $sString) Case Else ; Unsupported Where __IEConsoleWriteError("Error", "_IEDocInsertHTML", "$_IESTATUS_InvalidValue", "Invalid where value") Return SetError($_IESTATUS_InvalidValue, 3, 0) EndSelect If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEDocInsertHTML", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf Return SetError($_IESTATUS_Success, 0, 1) EndFunc ;==>_IEDocInsertHTML ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; Modified ......: jpm ; =============================================================================================================================== Func _IEHeadInsertEventScript(ByRef $oObject, $sHTMLFor, $sEvent, $sScript) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEHeadInsertEventScript", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf Local $oHead = $oObject.document.all.tags("HEAD").Item(0) Local $oScript = $oObject.document.createElement("script") If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEHeadInsertEventScript(script)", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf With $oScript .defer = True .language = "jscript" .type = "text/javascript" .htmlFor = $sHTMLFor .event = $sEvent .text = $sScript EndWith $oHead.appendChild($oScript) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEHeadInsertEventScript", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf Return SetError($_IESTATUS_Success, 0, 1) EndFunc ;==>_IEHeadInsertEventScript #EndRegion Read/Write functions #Region Utility functions ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEDocGetObj(ByRef $oObject) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEDocGetObj", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If __IEIsObjType($oObject, "document") Then Return SetError($_IESTATUS_Success, 0, $oObject) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.document) EndFunc ;==>_IEDocGetObj ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IETagNameGetCollection(ByRef $oObject, $sTagName, $iIndex = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IETagNameGetCollection", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IETagNameGetCollection", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Local $oTemp If __IEIsObjType($oObject, "documentcontainer") Then $oTemp = _IEDocGetObj($oObject) Else $oTemp = $oObject EndIf $iIndex = Number($iIndex) Select Case $iIndex = -1 Return SetError($_IESTATUS_Success, $oTemp.GetElementsByTagName($sTagName).length, _ $oTemp.GetElementsByTagName($sTagName)) Case $iIndex > -1 And $iIndex < $oTemp.GetElementsByTagName($sTagName).length Return SetError($_IESTATUS_Success, $oTemp.GetElementsByTagName($sTagName).length, _ $oTemp.GetElementsByTagName($sTagName).item($iIndex)) Case $iIndex < -1 __IEConsoleWriteError("Error", "_IETagNameGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1") Return SetError($_IESTATUS_InvalidValue, 3, 0) Case Else __IEConsoleWriteError("Error", "_IETagNameGetCollection", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both EndSelect EndFunc ;==>_IETagNameGetCollection ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IETagNameAllGetCollection(ByRef $oObject, $iIndex = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IETagNameAllGetCollection", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IETagNameAllGetCollection", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Local $oTemp If __IEIsObjType($oObject, "documentcontainer") Then $oTemp = _IEDocGetObj($oObject) Else $oTemp = $oObject EndIf $iIndex = Number($iIndex) Select Case $iIndex = -1 Return SetError($_IESTATUS_Success, $oTemp.all.length, $oTemp.all) Case $iIndex > -1 And $iIndex < $oTemp.all.length Return SetError($_IESTATUS_Success, $oTemp.all.length, $oTemp.all.item($iIndex)) Case $iIndex < -1 __IEConsoleWriteError("Error", "_IETagNameAllGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1") Return SetError($_IESTATUS_InvalidValue, 2, 0) Case Else __IEConsoleWriteError("Error", "_IETagNameAllGetCollection", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 1, 0) EndSelect EndFunc ;==>_IETagNameAllGetCollection ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEGetObjByName(ByRef $oObject, $sName, $iIndex = 0) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEGetObjByName", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; $iIndex = Number($iIndex) If $iIndex = -1 Then Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByName($sName).length, _ $oObject.document.GetElementsByName($sName)) Else If IsObj($oObject.document.GetElementsByName($sName).item($iIndex)) Then Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByName($sName).length, _ $oObject.document.GetElementsByName($sName).item($iIndex)) Else __IEConsoleWriteError("Warning", "_IEGetObjByName", "$_IESTATUS_NoMatch", "Name: " & $sName & ", Index: " & $iIndex) Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both EndIf EndIf EndFunc ;==>_IEGetObjByName ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEGetObjById(ByRef $oObject, $sID) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEGetObjById", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IEGetObById", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; If IsObj($oObject.document.getElementById($sID)) Then Return SetError($_IESTATUS_Success, 0, $oObject.document.getElementById($sID)) Else __IEConsoleWriteError("Warning", "_IEGetObjById", "$_IESTATUS_NoMatch", $sID) Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf EndFunc ;==>_IEGetObjById ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEAction(ByRef $oObject, $sAction) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; $sAction = StringLower($sAction) Select ; DOM objects Case $sAction = "click" If __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IEAction(click)", " $_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Click() Case $sAction = "disable" If __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IEAction(disable)", " $_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.disabled = True Case $sAction = "enable" If __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IEAction(enable)", " $_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.disabled = False Case $sAction = "focus" If __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IEAction(focus)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Focus() Case $sAction = "scrollintoview" If __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IEAction(scrollintoview)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.scrollIntoView() ; Browser Object Case $sAction = "copy" $oObject.document.execCommand("Copy") Case $sAction = "cut" $oObject.document.execCommand("Cut") Case $sAction = "paste" $oObject.document.execCommand("Paste") Case $sAction = "delete" $oObject.document.execCommand("Delete") Case $sAction = "saveas" $oObject.document.execCommand("SaveAs") Case $sAction = "refresh" $oObject.document.execCommand("Refresh") If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEAction(refresh)", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf _IELoadWait($oObject) Case $sAction = "selectall" $oObject.document.execCommand("SelectAll") Case $sAction = "unselect" $oObject.document.execCommand("Unselect") Case $sAction = "print" $oObject.document.parentwindow.Print() Case $sAction = "printdefault" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEAction(printdefault)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.execWB(6, 2) Case $sAction = "back" If Not __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IEAction(back)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.GoBack() Case $sAction = "blur" $oObject.Blur() Case $sAction = "forward" If Not __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IEAction(forward)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.GoForward() Case $sAction = "home" If Not __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IEAction(home)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.GoHome() Case $sAction = "invisible" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEAction(invisible)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.visible = 0 Case $sAction = "visible" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEAction(visible)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.visible = 1 Case $sAction = "search" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEAction(search)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.GoSearch() Case $sAction = "stop" If Not __IEIsObjType($oObject, "documentContainer") Then __IEConsoleWriteError("Error", "_IEAction(stop)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Stop() Case $sAction = "quit" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEAction(quit)", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Quit() If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf $oObject = 0 Return SetError($_IESTATUS_Success, 0, 1) Case Else ; Unsupported Action __IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_InvalidValue", "Invalid Action") Return SetError($_IESTATUS_InvalidValue, 2, 0) EndSelect If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf Return SetError($_IESTATUS_Success, 0, 1) EndFunc ;==>_IEAction ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEPropertyGet(ByRef $oObject, $sProperty) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; Local $oTemp, $iTemp $sProperty = StringLower($sProperty) Select Case $sProperty = "browserx" If __IEIsObjType($oObject, "browsercontainer") Or __IEIsObjType($oObject, "document") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oTemp = $oObject $iTemp = 0 While IsObj($oTemp) $iTemp += $oTemp.offsetLeft $oTemp = $oTemp.offsetParent WEnd Return SetError($_IESTATUS_Success, 0, $iTemp) Case $sProperty = "browsery" If __IEIsObjType($oObject, "browsercontainer") Or __IEIsObjType($oObject, "document") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oTemp = $oObject $iTemp = 0 While IsObj($oTemp) $iTemp += $oTemp.offsetTop $oTemp = $oTemp.offsetParent WEnd Return SetError($_IESTATUS_Success, 0, $iTemp) Case $sProperty = "screenx" If __IEIsObjType($oObject, "window") Or __IEIsObjType($oObject, "document") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If __IEIsObjType($oObject, "browser") Then Return SetError($_IESTATUS_Success, 0, $oObject.left()) Else $oTemp = $oObject $iTemp = 0 While IsObj($oTemp) $iTemp += $oTemp.offsetLeft $oTemp = $oTemp.offsetParent WEnd EndIf Return SetError($_IESTATUS_Success, 0, _ $iTemp + $oObject.document.parentWindow.screenLeft) Case $sProperty = "screeny" If __IEIsObjType($oObject, "window") Or __IEIsObjType($oObject, "document") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If __IEIsObjType($oObject, "browser") Then Return SetError($_IESTATUS_Success, 0, $oObject.top()) Else $oTemp = $oObject $iTemp = 0 While IsObj($oTemp) $iTemp += $oTemp.offsetTop $oTemp = $oTemp.offsetParent WEnd EndIf Return SetError($_IESTATUS_Success, 0, _ $iTemp + $oObject.document.parentWindow.screenTop) Case $sProperty = "height" If __IEIsObjType($oObject, "window") Or __IEIsObjType($oObject, "document") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If __IEIsObjType($oObject, "browser") Then Return SetError($_IESTATUS_Success, 0, $oObject.Height()) Else Return SetError($_IESTATUS_Success, 0, $oObject.offsetHeight) EndIf Case $sProperty = "width" If __IEIsObjType($oObject, "window") Or __IEIsObjType($oObject, "document") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If __IEIsObjType($oObject, "browser") Then Return SetError($_IESTATUS_Success, 0, $oObject.Width()) Else Return SetError($_IESTATUS_Success, 0, $oObject.offsetWidth) EndIf Case $sProperty = "isdisabled" Return SetError($_IESTATUS_Success, 0, $oObject.isDisabled()) Case $sProperty = "addressbar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.AddressBar()) Case $sProperty = "busy" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.Busy()) Case $sProperty = "fullscreen" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.fullScreen()) Case $sProperty = "hwnd" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, HWnd($oObject.HWnd())) Case $sProperty = "left" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.Left()) Case $sProperty = "locationname" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.LocationName()) Case $sProperty = "locationurl" If __IEIsObjType($oObject, "browser") Then Return SetError($_IESTATUS_Success, 0, $oObject.locationURL()) EndIf If __IEIsObjType($oObject, "window") Then Return SetError($_IESTATUS_Success, 0, $oObject.location.href()) EndIf If __IEIsObjType($oObject, "document") Then Return SetError($_IESTATUS_Success, 0, $oObject.parentwindow.location.href()) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.document.parentwindow.location.href()) Case $sProperty = "menubar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.MenuBar()) Case $sProperty = "offline" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.OffLine()) Case $sProperty = "readystate" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.ReadyState()) Case $sProperty = "resizable" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.Resizable()) Case $sProperty = "silent" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.Silent()) Case $sProperty = "statusbar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.StatusBar()) Case $sProperty = "statustext" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.StatusText()) Case $sProperty = "top" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.Top()) Case $sProperty = "visible" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.Visible()) Case $sProperty = "appcodename" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.appCodeName()) Case $sProperty = "appminorversion" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.appMinorVersion()) Case $sProperty = "appname" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.appName()) Case $sProperty = "appversion" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.appVersion()) Case $sProperty = "browserlanguage" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.browserLanguage()) Case $sProperty = "cookieenabled" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.cookieEnabled()) Case $sProperty = "cpuclass" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.cpuClass()) Case $sProperty = "javaenabled" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.javaEnabled()) Case $sProperty = "online" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.onLine()) Case $sProperty = "platform" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.platform()) Case $sProperty = "systemlanguage" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.systemLanguage()) Case $sProperty = "useragent" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.userAgent()) Case $sProperty = "userlanguage" Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.userLanguage()) Case $sProperty = "referrer" Return SetError($_IESTATUS_Success, 0, $oObject.document.referrer) Case $sProperty = "theatermode" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.TheaterMode) Case $sProperty = "toolbar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf Return SetError($_IESTATUS_Success, 0, $oObject.ToolBar) Case $sProperty = "contenteditable" If __IEIsObjType($oObject, "browser") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf Return SetError($_IESTATUS_Success, 0, $oTemp.isContentEditable) Case $sProperty = "innertext" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf Return SetError($_IESTATUS_Success, 0, $oTemp.innerText) Case $sProperty = "outertext" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf Return SetError($_IESTATUS_Success, 0, $oTemp.outerText) Case $sProperty = "innerhtml" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf Return SetError($_IESTATUS_Success, 0, $oTemp.innerHTML) Case $sProperty = "outerhtml" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf Return SetError($_IESTATUS_Success, 0, $oTemp.outerHTML) Case $sProperty = "title" Return SetError($_IESTATUS_Success, 0, $oObject.document.title) Case $sProperty = "uniqueid" If __IEIsObjType($oObject, "window") Then __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) Else Return SetError($_IESTATUS_Success, 0, $oObject.uniqueID) EndIf Case Else ; Unsupported Property __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidValue", "Invalid Property") Return SetError($_IESTATUS_InvalidValue, 2, 0) EndSelect EndFunc ;==>_IEPropertyGet ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEPropertySet(ByRef $oObject, $sProperty, $vValue) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; Local $oTemp #forceref $oTemp $sProperty = StringLower($sProperty) Select Case $sProperty = "addressbar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.AddressBar = $vValue Case $sProperty = "height" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Height = $vValue Case $sProperty = "left" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Left = $vValue Case $sProperty = "menubar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.MenuBar = $vValue Case $sProperty = "offline" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.OffLine = $vValue Case $sProperty = "resizable" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Resizable = $vValue Case $sProperty = "statusbar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.StatusBar = $vValue Case $sProperty = "statustext" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.StatusText = $vValue Case $sProperty = "top" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Top = $vValue Case $sProperty = "width" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Width = $vValue Case $sProperty = "theatermode" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If $vValue Then $oObject.TheaterMode = True Else $oObject.TheaterMode = False EndIf Case $sProperty = "toolbar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If $vValue Then $oObject.ToolBar = True Else $oObject.ToolBar = False EndIf Case $sProperty = "contenteditable" If __IEIsObjType($oObject, "browser") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf If $vValue Then $oTemp.contentEditable = "true" Else $oTemp.contentEditable = "false" EndIf Case $sProperty = "innertext" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf $oTemp.innerText = $vValue Case $sProperty = "outertext" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf $oTemp.outerText = $vValue Case $sProperty = "innerhtml" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf $oTemp.innerHTML = $vValue Case $sProperty = "outerhtml" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf $oTemp.outerHTML = $vValue Case $sProperty = "title" $oObject.document.title = $vValue Case $sProperty = "silent" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If $vValue Then $oObject.silent = True Else $oObject.silent = False EndIf Case Else ; Unsupported Property __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidValue", "Invalid Property") Return SetError($_IESTATUS_InvalidValue, 2, 0) EndSelect If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf Return SetError($_IESTATUS_Success, 0, 0) EndFunc ;==>_IEPropertySet ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; Modified ......: jpm ; =============================================================================================================================== Func _IEErrorNotify($vNotify = Default) If $vNotify = Default Then Return $__g_bIEErrorNotify If $vNotify Then $__g_bIEErrorNotify = True Else $__g_bIEErrorNotify = False EndIf Return 1 EndFunc ;==>_IEErrorNotify ; #NO_DOC_FUNCTION# ============================================================================================================= ; Name...........: _IEErrorHandlerRegister ; Description ...: Register and enable a user COM error handler ; Parameters ....: $sFunctionName - String variable with the name of a user-defined COM error handler ; defaults to the internal COM error handler in this UDF ; Return values .: On Success - Returns 1 ; On Failure - Returns 0 and sets @error ; @error - 0 ($_IEStatus_Success) = No Error ; - 1 ($_IEStatus_GeneralError) = General Error ; @extended - Contains invalid parameter number ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEErrorHandlerRegister($sFunctionName = "__IEInternalErrorHandler") $__g_oIEErrorHandler = ObjEvent("AutoIt.Error", $sFunctionName) If IsObj($__g_oIEErrorHandler) Then $__g_sIEUserErrorHandler = $sFunctionName Return SetError($_IESTATUS_Success, 0, 1) Else $__g_oIEErrorHandler = "" __IEConsoleWriteError("Error", "_IEErrorHandlerRegister", "$_IEStatus_GeneralError", _ "Error Handler Not Registered - Check existance of error function") Return SetError($_IEStatus_GeneralError, 1, 0) EndIf EndFunc ;==>_IEErrorHandlerRegister ; #NO_DOC_FUNCTION# ============================================================================================================= ; Name...........: _IEErrorHandlerDeRegister ; Description ...: Disable a registered user COM error handler ; Parameters ....: None ; Return values .: On Success - Returns 1 ; On Failure - None ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEErrorHandlerDeRegister() $__g_sIEUserErrorHandler = "" $__g_oIEErrorHandler = "" Return SetError($_IESTATUS_Success, 0, 1) EndFunc ;==>_IEErrorHandlerDeRegister ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IEInternalErrorHandlerRegister ; Description ...: to be called on error ; Author ........: Dale Hohm ; Modified ......: ; =============================================================================================================================== Func __IEInternalErrorHandlerRegister() Local $sCurrentErrorHandler = ObjEvent("AutoIt.Error") If $sCurrentErrorHandler <> "" And Not IsObj($__g_oIEErrorHandler) Then ; We've got trouble... User COM Error handler assigned without using _IEUserErrorHandlerRegister Return SetError($_IEStatus_GeneralError, 0, False) EndIf $__g_oIEErrorHandler = ObjEvent("AutoIt.Error", "__IEInternalErrorHandler") If IsObj($__g_oIEErrorHandler) Then Return SetError($_IESTATUS_Success, 0, True) Else $__g_oIEErrorHandler = "" Return SetError($_IEStatus_GeneralError, 0, False) EndIf EndFunc ;==>__IEInternalErrorHandlerRegister Func __IEInternalErrorHandlerDeRegister() $__g_oIEErrorHandler = "" If $__g_sIEUserErrorHandler <> "" Then $__g_oIEErrorHandler = ObjEvent("AutoIt.Error", $__g_sIEUserErrorHandler) EndIf Return SetError($_IESTATUS_Success, 0, 1) EndFunc ;==>__IEInternalErrorHandlerDeRegister ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IEInternalErrorHandler ; Description ...: to be called on error ; Author ........: Dale Hohm ; Modified ......: ; =============================================================================================================================== Func __IEInternalErrorHandler($oCOMError) If $__g_bIEErrorNotify Or $__g_bIEAU3Debug Then ConsoleWrite("--> " & __COMErrorFormating($oCOMError, "----> $IEComError") & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>__IEInternalErrorHandler ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEQuit(ByRef $oObject) ;~ Local $sName_IEQuit = String(ObjName($oObject)) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEQuit", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEQuit", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; $oObject.quit() If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IEQuit", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf $oObject = 0 Return SetError($_IESTATUS_Success, 0, 1) EndFunc ;==>_IEQuit #EndRegion Utility functions #Region General ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; Modified ......: jpm ; =============================================================================================================================== Func _IE_Introduction($sModule = "basic") Local $sHTML = "" Switch $sModule Case "basic" $sHTML &= '' & @CR $sHTML &= '' & @CR $sHTML &= '
' & @CR $sHTML &= '' & @CR $sHTML &= '' & @CR
$sHTML &= 'Welcome to IE.au3' & @CR $sHTML &= 'IE.au3 is a UDF (User Defined Function) library for the ' & @CR $sHTML &= 'AutoIt scripting language.' & @CR $sHTML &= '' & @CR $sHTML &= 'IE.au3 allows you to either create or attach to an Internet Explorer browser and do ' & @CR $sHTML &= 'just about anything you could do with it interactively with the mouse and ' & @CR $sHTML &= 'keyboard, but do it through script.' & @CR $sHTML &= ' ' & @CR $sHTML &= 'You can navigate to pages, click links, fill and submit forms etc. You can ' & @CR $sHTML &= 'also do things you cannot do interactively like change or rewrite page ' & @CR $sHTML &= 'content and JavaScripts, read, parse and save page content and monitor and act ' & @CR $sHTML &= 'upon browser "events". ' & @CR $sHTML &= 'IE.au3 uses the COM interface in AutoIt to interact with the Internet Explorer ' & @CR $sHTML &= 'object model and the DOM (Document Object Model) supported by the browser.' & @CR $sHTML &= ' ' & @CR $sHTML &= 'Here are some links for more information and helpful tools: ' & @CR $sHTML &= 'Reference Material: ' & @CR $sHTML &= '
' & @CR $sHTML &= 'Helpful Tools: ' & @CR $sHTML &= '
| ' & @CR
$sHTML &= '
AutoIt | ' & @CR $sHTML &= 'is | ' & @CR $sHTML &= 'really | ' & @CR $sHTML &= 'great | ' & @CR $sHTML &= 'with | ' & @CR $sHTML &= 'IE.au3 | ' & @CR $sHTML &= '
1 | ' & @CR $sHTML &= '2 | ' & @CR $sHTML &= '3 | ' & @CR $sHTML &= '4 | ' & @CR $sHTML &= '5 | ' & @CR $sHTML &= '6 | ' & @CR $sHTML &= '
the | ' & @CR $sHTML &= 'quick | ' & @CR $sHTML &= 'red | ' & @CR $sHTML &= 'fox | ' & @CR $sHTML &= 'jumped | ' & @CR $sHTML &= 'over | ' & @CR $sHTML &= '
the | ' & @CR $sHTML &= 'lazy | ' & @CR $sHTML &= 'brown | ' & @CR $sHTML &= 'dog | ' & @CR $sHTML &= 'the | ' & @CR $sHTML &= 'time | ' & @CR $sHTML &= '
has | ' & @CR $sHTML &= 'come | ' & @CR $sHTML &= 'for | ' & @CR $sHTML &= 'all | ' & @CR $sHTML &= 'good | ' & @CR $sHTML &= 'men | ' & @CR $sHTML &= '
to | ' & @CR $sHTML &= 'come | ' & @CR $sHTML &= 'to | ' & @CR $sHTML &= 'the | ' & @CR $sHTML &= 'aid | ' & @CR $sHTML &= 'of | ' & @CR $sHTML &= '
Table Top | ' & @CR $sHTML &= '|||
One | ' & @CR $sHTML &= 'Two | ' & @CR $sHTML &= '||
Three | ' & @CR $sHTML &= 'Four | ' & @CR $sHTML &= 'Five | ' & @CR $sHTML &= '|
Six | ' & @CR $sHTML &= 'Seven | ' & @CR $sHTML &= '||
Eight | ' & @CR $sHTML &= 'Nine | ' & @CR $sHTML &= 'Ten | ' & @CR $sHTML &= 'Eleven | ' & @CR $sHTML &= '
' & @CR $sHTML &= ' | <iframe name="iFrameOne" src="about:blank" title="iFrameOne"> | ' & @CR $sHTML &= '
' & @CR $sHTML &= ' | <iframe name="iFrameTwo" src="about:blank" title="iFrameTwo"> | ' & @CR $sHTML &= '