#include-once #include "AutoItConstants.au3" #include "FileConstants.au3" #include "WinAPIError.au3" ; #INDEX# ======================================================================================================================= ; Title .........: Internet Explorer Automation UDF Library for AutoIt3 ; AutoIt Version : 3.3.12.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 Version: T3.0-1 Last Update: 13/06/02 Requirements: AutoIt3 3.3.9 or higher Update History: =================================================== 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 $o__IEErrorHandler, $s__IEUserErrorHandler ;~ Global _; Com Error Handler Status Strings ;~ $IEComErrorNumber, _ ;~ $IEComErrorNumberHex, _ ;~ $IEComErrorDescription, _ ;~ $IEComErrorScriptline, _ ;~ $IEComErrorWinDescription, _ ;~ $IEComErrorSource, _ ;~ $IEComErrorHelpFile, _ ;~ $IEComErrorHelpContext, _ ;~ $IEComErrorLastDllError, _ ;~ $IEComErrorComObj, _ ;~ $IEComErrorOutput #EndRegion Global Variables ; =============================================================================================================================== ; #CONSTANTS# =================================================================================================================== #Region Global Constants Global Const $__gaIEAU3VersionInfo[6] = ["T", 3, 0, 1, "20130601", "T3.0-1"] 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 ; =============================================================================================================================== ; #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 ; ; __IENavigate ; __IEStringToBstr ; __IEBstrToString ; __IECreateNewIE ; __IETempFile ; =============================================================================================================================== #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 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 ; 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 ;------------------------------------------------------------------------------------------ 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 ; Turn off error notification for internal processing 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"); 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") ; 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") ; 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 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 securuty 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, $sNewvalue) 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 = $sNewvalue Case $sProperty = "height" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Height = $sNewvalue Case $sProperty = "left" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Left = $sNewvalue Case $sProperty = "menubar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.MenuBar = $sNewvalue Case $sProperty = "offline" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.OffLine = $sNewvalue Case $sProperty = "resizable" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Resizable = $sNewvalue Case $sProperty = "statusbar" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.StatusBar = $sNewvalue Case $sProperty = "statustext" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.StatusText = $sNewvalue Case $sProperty = "top" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Top = $sNewvalue Case $sProperty = "width" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf $oObject.Width = $sNewvalue Case $sProperty = "theatermode" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If $sNewvalue 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 $sNewvalue 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 $sNewvalue 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 = $sNewvalue Case $sProperty = "outertext" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf $oTemp.outerText = $sNewvalue Case $sProperty = "innerhtml" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf $oTemp.innerHTML = $sNewvalue Case $sProperty = "outerhtml" If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then $oTemp = $oObject.document.body Else $oTemp = $oObject EndIf $oTemp.outerHTML = $sNewvalue Case $sProperty = "title" $oObject.document.title = $sNewvalue Case $sProperty = "silent" If Not __IEIsObjType($oObject, "browser") Then __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf If $sNewvalue 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 ; #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 &= '