Jump to content
Sign in to follow this  
XinYoung

Need Help With _IETableGetCollection (i think)

Recommended Posts

Hello all and happy holidays!

Years ago, a former co-worker of mine wrote a brilliant script to automate several time-consuming tedious tasks. Unfortunately, he left -- and this isn't any of our area of expertise, but he left behind his code for me to tinker with.

The script uses Excel and IE together. In a nutshell, it navigates to a particular website, using their search tool to look for a string of text provided by an Excel workbook. If a result is found, it does something, if not found, it does something else. Due to a recent update on this website, the script thinks it's not getting a result from the search, but it actually is! It just can't see it!

I believe the problem lies with how the _IETableGetCollection function is being used -- because the search result is a table (screenshot below) -- and the script seems to look for cell 2,2 (I've tried changing it to 3,2, because of that checkbox but that didn't work). The result is there, but it doesn't see or recognize it.

 

image.thumb.png.6b858504b929db9656eb8f5affe94537.png

 

Here's the code for the UDF that uses _IETableGetCollection... where I think the problem lies:

Func _bbTableDataIndexSearch(ByRef $oObject, $TableIndex, $iColNum, $sSearchString)
Opt("WinTitleMatchMode", 2)
Sleep(100)
Local $oBBTable = _IETableGetCollection($oObject, $TableIndex)
Local $aBBTableData = _IETableWriteToArray($oBBTable)
_ArrayTranspose($aBBTableData)
For $iCountTableData = 1 To UBound($aBBTableData) - 1 Step 1
$aBBTableData[$iCountTableData][$iColNum] = StringStripWS($aBBTableData[$iCountTableData][$iColNum], 7)
Next
$sSearchString = StringReplace($sSearchString, " ", "")
$iIndexList = _ArraySearch($aBBTableData, $sSearchString) - 1
_IEImgClick($oObject, "/images/ci/icons/cmlink_generic.gif", "src", $iIndexList, 1)
If @error Then
Return 0
MsgBox($MB_ICONWARNING, "Not Found", "Course name " & $sSearchString & " not found.")
Else
Return 1
$oObject.fireEvent("OnChange")
EndIf
EndFunc

 

And this is what calls on that function. Every time I run the script, I get the "Else" result, even though the search result is there.

For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseExistStatus[$i] = "Yes" Then ContinueLoop
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseExist = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseExist = 1 Then
$oWorkbook.ActiveSheet.Range("F" & $i + 1).Value = "Yes"
$oWorkbook.ActiveSheet.Range("J" & $i + 1).Value = _bbCourseReturnID($aCourseToSearch[$i])
Else
$oWorkbook.ActiveSheet.Range("F" & $i + 1).Value = "No"
$oWorkbook.ActiveSheet.Range("J" & $i + 1).Value = "-"
EndIf
_Excel_BookSave($oWorkbook)
Sleep(1000)
Next

 

Please let me know if more information is needed. Any guidance you guys can provide is greatly appreciated.

Thank you!

 

Edited by XinYoung
Formatted the code for easy viewing

Share this post


Link to post
Share on other sites
Local $oBBTable = _IETableGetCollection($oObject, $TableIndex)
Local $aBBTableData = _IETableWriteToArray($oBBTable)

Just after, could you do _ArrayDisplay ($aBBTableData) and show us the result ?

Share this post


Link to post
Share on other sites
21 minutes ago, Nine said:
Local $oBBTable = _IETableGetCollection($oObject, $TableIndex)
Local $aBBTableData = _IETableWriteToArray($oBBTable)

Just after, could you do _ArrayDisplay ($aBBTableData) and show us the result ?

I'm getting:

error: _ArrayDisplay(): undefined function.

I tried adding #include <Array.au3> at the top but then it throws a ton of 'Const' errors. Come to think of it, there isn't any #include stuff in the script. I don't know how that works... Sorry I'm so bad at this.

Share this post


Link to post
Share on other sites

Something is wrong here.  The statement just after (_ArrayTranspose($aBBTableData)) should come from an #Include <Array.au3>.  I don't know what to say.  I would like to see the full script then.  Copy/paste it using <> (just before the emoticon)

Share this post


Link to post
Share on other sites
11 minutes ago, Nine said:

Something is wrong here.  The statement just after (_ArrayTranspose($aBBTableData)) should come from an #Include <Array.au3>.  I don't know what to say.  I would like to see the full script then.  Copy/paste it using <> (just before the emoticon)

OK, here it is. I only removed a few minor things for security...

#NoTrayIcon
Global Const $OPT_MATCHANY = 2
Global Const $UBOUND_DIMENSIONS = 0
Global Const $UBOUND_ROWS = 1
Global Const $UBOUND_COLUMNS = 2
Global Const $MB_YESNO = 4
Global Const $MB_ICONWARNING = 48
Global Const $IDYES = 6
Global Const $IDNO = 7
Global Const $STR_STRIPLEADING = 1
Global Const $STR_STRIPTRAILING = 2
Global Const $STR_ENTIRESPLIT = 1
Global Const $STR_NOCOUNT = 2
Global Const $STR_REGEXPARRAYMATCH = 1
Func _ArrayAdd(ByRef $avArray, $vValue, $iStart = 0, $sDelim_Item = "|", $sDelim_Row = @CRLF, $hDataType = 0)
If $iStart = Default Then $iStart = 0
If $sDelim_Item = Default Then $sDelim_Item = "|"
If $sDelim_Row = Default Then $sDelim_Row = @CRLF
If $hDataType = Default Then $hDataType = 0
If Not IsArray($avArray) Then Return SetError(1, 0, -1)
Local $iDim_1 = UBound($avArray, $UBOUND_ROWS)
Switch UBound($avArray, $UBOUND_DIMENSIONS)
Case 1
If IsArray($vValue) Then
If UBound($vValue, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(5, 0, -1)
$hDataType = 0
Else
Local $aTmp = StringSplit($vValue, $sDelim_Item, $STR_NOCOUNT + $STR_ENTIRESPLIT)
If UBound($aTmp, $UBOUND_ROWS) = 1 Then
$aTmp[0] = $vValue
$hDataType = 0
EndIf
$vValue = $aTmp
EndIf
Local $iAdd = UBound($vValue, $UBOUND_ROWS)
ReDim $avArray[$iDim_1 + $iAdd]
For $i = 0 To $iAdd - 1
If IsFunc($hDataType) Then
$avArray[$iDim_1 + $i] = $hDataType($vValue[$i])
Else
$avArray[$iDim_1 + $i] = $vValue[$i]
EndIf
Next
Return $iDim_1 + $iAdd - 1
Case 2
Local $iDim_2 = UBound($avArray, $UBOUND_COLUMNS)
If $iStart < 0 Or $iStart > $iDim_2 - 1 Then Return SetError(4, 0, -1)
Local $iValDim_1, $iValDim_2
If IsArray($vValue) Then
If UBound($vValue, $UBOUND_DIMENSIONS) <> 2 Then Return SetError(5, 0, -1)
$iValDim_1 = UBound($vValue, $UBOUND_ROWS)
$iValDim_2 = UBound($vValue, $UBOUND_COLUMNS)
$hDataType = 0
Else
Local $aSplit_1 = StringSplit($vValue, $sDelim_Row, $STR_NOCOUNT + $STR_ENTIRESPLIT)
$iValDim_1 = UBound($aSplit_1, $UBOUND_ROWS)
StringReplace($aSplit_1[0], $sDelim_Item, "")
$iValDim_2 = @extended + 1
Local $aTmp[$iValDim_1][$iValDim_2], $aSplit_2
For $i = 0 To $iValDim_1 - 1
$aSplit_2 = StringSplit($aSplit_1[$i], $sDelim_Item, $STR_NOCOUNT + $STR_ENTIRESPLIT)
For $j = 0 To $iValDim_2 - 1
$aTmp[$i][$j] = $aSplit_2[$j]
Next
Next
$vValue = $aTmp
EndIf
If UBound($vValue, $UBOUND_COLUMNS) + $iStart > UBound($avArray, $UBOUND_COLUMNS) Then Return SetError(3, 0, -1)
ReDim $avArray[$iDim_1 + $iValDim_1][$iDim_2]
For $iWriteTo_Index = 0 To $iValDim_1 - 1
For $j = 0 To $iDim_2 - 1
If $j < $iStart Then
$avArray[$iWriteTo_Index + $iDim_1][$j] = ""
ElseIf $j - $iStart > $iValDim_2 - 1 Then
$avArray[$iWriteTo_Index + $iDim_1][$j] = ""
Else
If IsFunc($hDataType) Then
$avArray[$iWriteTo_Index + $iDim_1][$j] = $hDataType($vValue[$iWriteTo_Index][$j - $iStart])
Else
$avArray[$iWriteTo_Index + $iDim_1][$j] = $vValue[$iWriteTo_Index][$j - $iStart]
EndIf
EndIf
Next
Next
Case Else
Return SetError(2, 0, -1)
EndSwitch
Return UBound($avArray, $UBOUND_ROWS) - 1
EndFunc
Func _ArrayFindAll(Const ByRef $avArray, $vValue, $iStart = 0, $iEnd = 0, $iCase = 0, $iCompare = 0, $iSubItem = 0, $bRow = False)
If $iStart = Default Then $iStart = 0
If $iEnd = Default Then $iEnd = 0
If $iCase = Default Then $iCase = 0
If $iCompare = Default Then $iCompare = 0
If $iSubItem = Default Then $iSubItem = 0
If $bRow = Default Then $bRow = False
$iStart = _ArraySearch($avArray, $vValue, $iStart, $iEnd, $iCase, $iCompare, 1, $iSubItem, $bRow)
If @error Then Return SetError(@error, 0, -1)
Local $iIndex = 0, $avResult[UBound($avArray)]
Do
$avResult[$iIndex] = $iStart
$iIndex += 1
$iStart = _ArraySearch($avArray, $vValue, $iStart + 1, $iEnd, $iCase, $iCompare, 1, $iSubItem, $bRow)
Until @error
ReDim $avResult[$iIndex]
Return $avResult
EndFunc
Func _ArraySearch(Const ByRef $avArray, $vValue, $iStart = 0, $iEnd = 0, $iCase = 0, $iCompare = 0, $iForward = 1, $iSubItem = -1, $bRow = False)
If $iStart = Default Then $iStart = 0
If $iEnd = Default Then $iEnd = 0
If $iCase = Default Then $iCase = 0
If $iCompare = Default Then $iCompare = 0
If $iForward = Default Then $iForward = 1
If $iSubItem = Default Then $iSubItem = -1
If $bRow = Default Then $bRow = False
If Not IsArray($avArray) Then Return SetError(1, 0, -1)
Local $iDim_1 = UBound($avArray) - 1
If $iDim_1 = -1 Then Return SetError(3, 0, -1)
Local $iDim_2 = UBound($avArray, $UBOUND_COLUMNS) - 1
Local $bCompType = False
If $iCompare = 2 Then
$iCompare = 0
$bCompType = True
EndIf
If $bRow Then
If UBound($avArray, $UBOUND_DIMENSIONS) = 1 Then Return SetError(5, 0, -1)
If $iEnd < 1 Or $iEnd > $iDim_2 Then $iEnd = $iDim_2
If $iStart < 0 Then $iStart = 0
If $iStart > $iEnd Then Return SetError(4, 0, -1)
Else
If $iEnd < 1 Or $iEnd > $iDim_1 Then $iEnd = $iDim_1
If $iStart < 0 Then $iStart = 0
If $iStart > $iEnd Then Return SetError(4, 0, -1)
EndIf
Local $iStep = 1
If Not $iForward Then
Local $iTmp = $iStart
$iStart = $iEnd
$iEnd = $iTmp
$iStep = -1
EndIf
Switch UBound($avArray, $UBOUND_DIMENSIONS)
Case 1
If Not $iCompare Then
If Not $iCase Then
For $i = $iStart To $iEnd Step $iStep
If $bCompType And VarGetType($avArray[$i]) <> VarGetType($vValue) Then ContinueLoop
If $avArray[$i] = $vValue Then Return $i
Next
Else
For $i = $iStart To $iEnd Step $iStep
If $bCompType And VarGetType($avArray[$i]) <> VarGetType($vValue) Then ContinueLoop
If $avArray[$i] == $vValue Then Return $i
Next
EndIf
Else
For $i = $iStart To $iEnd Step $iStep
If $iCompare = 3 Then
If StringRegExp($avArray[$i], $vValue) Then Return $i
Else
If StringInStr($avArray[$i], $vValue, $iCase) > 0 Then Return $i
EndIf
Next
EndIf
Case 2
Local $iDim_Sub
If $bRow Then
$iDim_Sub = $iDim_1
If $iSubItem > $iDim_Sub Then $iSubItem = $iDim_Sub
If $iSubItem < 0 Then
$iSubItem = 0
Else
$iDim_Sub = $iSubItem
EndIf
Else
$iDim_Sub = $iDim_2
If $iSubItem > $iDim_Sub Then $iSubItem = $iDim_Sub
If $iSubItem < 0 Then
$iSubItem = 0
Else
$iDim_Sub = $iSubItem
EndIf
EndIf
For $j = $iSubItem To $iDim_Sub
If Not $iCompare Then
If Not $iCase Then
For $i = $iStart To $iEnd Step $iStep
If $bRow Then
If $bCompType And VarGetType($avArray[$j][$j]) <> VarGetType($vValue) Then ContinueLoop
If $avArray[$j][$i] = $vValue Then Return $i
Else
If $bCompType And VarGetType($avArray[$i][$j]) <> VarGetType($vValue) Then ContinueLoop
If $avArray[$i][$j] = $vValue Then Return $i
EndIf
Next
Else
For $i = $iStart To $iEnd Step $iStep
If $bRow Then
If $bCompType And VarGetType($avArray[$j][$i]) <> VarGetType($vValue) Then ContinueLoop
If $avArray[$j][$i] == $vValue Then Return $i
Else
If $bCompType And VarGetType($avArray[$i][$j]) <> VarGetType($vValue) Then ContinueLoop
If $avArray[$i][$j] == $vValue Then Return $i
EndIf
Next
EndIf
Else
For $i = $iStart To $iEnd Step $iStep
If $iCompare = 3 Then
If $bRow Then
If StringRegExp($avArray[$j][$i], $vValue) Then Return $i
Else
If StringRegExp($avArray[$i][$j], $vValue) Then Return $i
EndIf
Else
If $bRow Then
If StringInStr($avArray[$j][$i], $vValue, $iCase) > 0 Then Return $i
Else
If StringInStr($avArray[$i][$j], $vValue, $iCase) > 0 Then Return $i
EndIf
EndIf
Next
EndIf
Next
Case Else
Return SetError(2, 0, -1)
EndSwitch
Return SetError(6, 0, -1)
EndFunc
Func _ArrayTranspose(ByRef $avArray)
Switch UBound($avArray, 0)
Case 0
Return SetError(2, 0, 0)
Case 1
Local $aTemp[1][UBound($avArray)]
For $i = 0 To UBound($avArray) - 1
$aTemp[0][$i] = $avArray[$i]
Next
$avArray = $aTemp
Return 1
Case 2
Local $vElement, $iDim_1 = UBound($avArray, 1), $iDim_2 = UBound($avArray, 2), $iDim_Max =($iDim_1 > $iDim_2) ? $iDim_1 : $iDim_2
If $iDim_Max <= 4096 Then
ReDim $avArray[$iDim_Max][$iDim_Max]
For $i = 0 To $iDim_Max - 2
For $j = $i + 1 To $iDim_Max - 1
$vElement = $avArray[$i][$j]
$avArray[$i][$j] = $avArray[$j][$i]
$avArray[$j][$i] = $vElement
Next
Next
If $iDim_1 = 1 Then
Local $aTemp[$iDim_2]
For $i = 0 To $iDim_2 - 1
$aTemp[$i] = $avArray[$i][0]
Next
$avArray = $aTemp
Else
ReDim $avArray[$iDim_2][$iDim_1]
EndIf
Else
Local $aTemp[$iDim_2][$iDim_1]
For $i = 0 To $iDim_1 - 1
For $j = 0 To $iDim_2 - 1
$aTemp[$j][$i] = $avArray[$i][$j]
Next
Next
ReDim $avArray[$iDim_2][$iDim_1]
$avArray = $aTemp
EndIf
Return 1
Case Else
Return SetError(1, 0, 0)
EndSwitch
EndFunc
Func _Excel_Open($bVisible = Default, $bDisplayAlerts = Default, $bScreenUpdating = Default, $bInteractive = Default, $bForceNew = Default)
Local $oExcel, $bApplCloseOnQuit = False
If $bVisible = Default Then $bVisible = True
If $bDisplayAlerts = Default Then $bDisplayAlerts = False
If $bScreenUpdating = Default Then $bScreenUpdating = True
If $bInteractive = Default Then $bInteractive = True
If $bForceNew = Default Then $bForceNew = False
If Not $bForceNew Then $oExcel = ObjGet("", "Excel.Application")
If $bForceNew Or @error Then
$oExcel = ObjCreate("Excel.Application")
If @error Or Not IsObj($oExcel) Then Return SetError(1, @error, 0)
$bApplCloseOnQuit = True
EndIf
__Excel_CloseOnQuit($oExcel, $bApplCloseOnQuit)
$oExcel.Visible = $bVisible
$oExcel.DisplayAlerts = $bDisplayAlerts
$oExcel.ScreenUpdating = $bScreenUpdating
$oExcel.Interactive = $bInteractive
Return SetError(0, $bApplCloseOnQuit, $oExcel)
EndFunc
Func _Excel_BookOpen($oExcel, $sFilePath, $bReadOnly = Default, $bVisible = Default, $sPassword = Default, $sWritePassword = Default)
If Not IsObj($oExcel) Or ObjName($oExcel, 1) <> "_Application" Then Return SetError(1, @error, 0)
If Not FileExists($sFilePath) Then Return SetError(2, 0, 0)
If $bReadOnly = Default Then $bReadOnly = False
If $bVisible = Default Then $bVisible = True
Local $oWorkbook = $oExcel.Workbooks.Open($sFilePath, Default, $bReadOnly, Default, $sPassword, $sWritePassword)
If @error Then Return SetError(3, @error, 0)
$oExcel.Windows($oWorkbook.Name).Visible = $bVisible
If $bReadOnly = False And $oWorkbook.Readonly = True Then Return SetError(4, 0, $oWorkbook)
Return $oWorkbook
EndFunc
Func _Excel_BookSave($oWorkbook)
If Not IsObj($oWorkbook) Or ObjName($oWorkbook, 1) <> "_Workbook" Then Return SetError(1, 0, 0)
If Not $oWorkbook.Saved Then
$oWorkbook.Save()
If @error Then Return SetError(2, @error, 0)
Return SetError(0, 1, 1)
EndIf
Return 1
EndFunc
Func _Excel_RangeRead($oWorkbook, $vWorksheet = Default, $vRange = Default, $iReturn = Default, $bForceFunc = Default)
If Not IsObj($oWorkbook) Or ObjName($oWorkbook, 1) <> "_Workbook" Then Return SetError(1, 0, 0)
If Not IsObj($vWorksheet) Then
If $vWorksheet = Default Then
$vWorksheet = $oWorkbook.ActiveSheet
Else
$vWorksheet = $oWorkbook.WorkSheets.Item($vWorksheet)
EndIf
If @error Or Not IsObj($vWorksheet) Then Return SetError(2, @error, 0)
ElseIf ObjName($vWorksheet, 1) <> "_Worksheet" Then
Return SetError(2, @error, 0)
EndIf
If $vRange = Default Then
$vRange = $vWorksheet.Usedrange
ElseIf Not IsObj($vRange) Then
$vRange = $vWorksheet.Range($vRange)
If @error Or Not IsObj($vRange) Then Return SetError(3, @error, 0)
EndIf
If $iReturn = Default Then
$iReturn = 1
ElseIf $iReturn < 1 Or $iReturn > 3 Then
Return SetError(4, 0, 0)
EndIf
If $bForceFunc = Default Then $bForceFunc = False
Local $vResult, $iCellCount = $vRange.Columns.Count * $vRange.Rows.Count
If $iCellCount > 16777216 Then Return SetError(6, 0, 0)
If $iCellCount > 65535 Then $bForceFunc = True
If $bForceFunc Then
If $iReturn = 1 Then
$vResult = $vRange.Value
ElseIf $iReturn = 2 Then
$vResult = $vRange.Formula
Else
$vResult = $vRange.Text
EndIf
If @error Then Return SetError(7, @error, 0)
If $iCellCount > 1 Then _ArrayTranspose($vResult)
Else
Local $oExcel = $oWorkbook.Parent
If $iReturn = 1 Then
$vResult = $oExcel.Transpose($vRange.Value)
ElseIf $iReturn = 2 Then
$vResult = $oExcel.Transpose($vRange.Formula)
Else
$vResult = $oExcel.Transpose($vRange.Text)
EndIf
If @error Then Return SetError(5, @error, 0)
EndIf
Return $vResult
EndFunc
Func __Excel_CloseOnQuit($oExcel, $bNewState = Default)
Static $bState[101] = [0]
If $bNewState = True Then
For $i = 1 To $bState[0]
If Not IsObj($bState[$i]) Or $bState[$i] = $oExcel Then
$bState[$i] = $oExcel
Return True
EndIf
Next
$bState[0] = $bState[0] + 1
$bState[$bState[0]] = $oExcel
Return True
Else
For $i = 1 To $bState[0]
If $bState[$i] = $oExcel Then
If $bNewState = False Then
$bState[$i] = 0
Return False
Else
Return True
EndIf
EndIf
Next
EndIf
Return False
EndFunc
Func _PathSplit($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension)
Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH)
If @error Then
ReDim $aArray[5]
$aArray[0] = $sFilePath
EndIf
$sDrive = $aArray[1]
If StringLeft($aArray[2], 1) == "/" Then
$sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\/")
Else
$sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\\")
EndIf
$sFileName = $aArray[3]
$sExtension = $aArray[4]
Return $aArray
EndFunc
Global Const $tagRECT = "struct;long Left;long Top;long Right;long Bottom;endstruct"
Global Const $tagSYSTEMTIME = "struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct"
Global Const $tagREBARBANDINFO = "uint cbSize;uint fMask;uint fStyle;dword clrFore;dword clrBack;ptr lpText;uint cch;" & "int iImage;hwnd hwndChild;uint cxMinChild;uint cyMinChild;uint cx;handle hbmBack;uint wID;uint cyChild;uint cyMaxChild;" & "uint cyIntegral;uint cxIdeal;lparam lParam;uint cxHeader" &((@OSVersion = "WIN_XP") ? "" : ";" & $tagRECT & ";uint uChevronState")
Global Const $tagSECURITY_ATTRIBUTES = "dword Length;ptr Descriptor;bool InheritHandle"
Func _WinAPI_GetLastError($iError = @error, $iExtended = @extended)
Local $aResult = DllCall("kernel32.dll", "dword", "GetLastError")
Return SetError($iError, $iExtended, $aResult[0])
EndFunc
Func _Singleton($sOccurenceName, $iFlag = 0)
Local Const $ERROR_ALREADY_EXISTS = 183
Local Const $SECURITY_DESCRIPTOR_REVISION = 1
Local $tSecurityAttributes = 0
If BitAND($iFlag, 2) Then
Local $tSecurityDescriptor = DllStructCreate("byte;byte;word;ptr[4]")
Local $aRet = DllCall("advapi32.dll", "bool", "InitializeSecurityDescriptor", "struct*", $tSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION)
If @error Then Return SetError(@error, @extended, 0)
If $aRet[0] Then
$aRet = DllCall("advapi32.dll", "bool", "SetSecurityDescriptorDacl", "struct*", $tSecurityDescriptor, "bool", 1, "ptr", 0, "bool", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aRet[0] Then
$tSecurityAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES)
DllStructSetData($tSecurityAttributes, 1, DllStructGetSize($tSecurityAttributes))
DllStructSetData($tSecurityAttributes, 2, DllStructGetPtr($tSecurityDescriptor))
DllStructSetData($tSecurityAttributes, 3, 0)
EndIf
EndIf
EndIf
Local $aHandle = DllCall("kernel32.dll", "handle", "CreateMutexW", "struct*", $tSecurityAttributes, "bool", 1, "wstr", $sOccurenceName)
If @error Then Return SetError(@error, @extended, 0)
Local $aLastError = DllCall("kernel32.dll", "dword", "GetLastError")
If @error Then Return SetError(@error, @extended, 0)
If $aLastError[0] = $ERROR_ALREADY_EXISTS Then
If BitAND($iFlag, 1) Then
DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $aHandle[0])
If @error Then Return SetError(@error, @extended, 0)
Return SetError($aLastError[0], $aLastError[0], 0)
Else
Exit -1
EndIf
EndIf
Return $aHandle[0]
EndFunc
Global Const $DMW_SHORTNAME = 1
Global Const $DMW_LOCALE_LONGNAME = 2
Global Const $HGDI_ERROR = Ptr(-1)
Global Const $INVALID_HANDLE_VALUE = Ptr(-1)
Global Const $WH_MSGFILTER = -1
Global Const $KF_EXTENDED = 0x0100
Global Const $KF_ALTDOWN = 0x2000
Global Const $KF_UP = 0x8000
Global Const $LLKHF_EXTENDED = BitShift($KF_EXTENDED, 8)
Global Const $LLKHF_ALTDOWN = BitShift($KF_ALTDOWN, 8)
Global Const $LLKHF_UP = BitShift($KF_UP, 8)
Func _WinAPI_GetCurrentThreadId()
Local $aResult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[0]
EndFunc
Func _WinAPI_SetWindowsHookEx($idHook, $pFn, $hMod, $iThreadId = 0)
Local $aResult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $idHook, "ptr", $pFn, "handle", $hMod, "dword", $iThreadId)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[0]
EndFunc
Global Const $LOCALE_SDATE = 0x001D
Global Const $LOCALE_STIME = 0x001E
Global Const $LOCALE_SSHORTDATE = 0x001F
Global Const $LOCALE_SLONGDATE = 0x0020
Global Const $LOCALE_STIMEFORMAT = 0x1003
Global Const $LOCALE_S1159 = 0x0028
Global Const $LOCALE_S2359 = 0x0029
Global Const $LOCALE_INVARIANT = 0x007F
Global Const $LOCALE_USER_DEFAULT = 0x0400
Global Const $tagOSVERSIONINFO = 'struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct'
Global Const $__WINVER = __WINVER()
Func __WINVER()
Local $tOSVI = DllStructCreate($tagOSVERSIONINFO)
DllStructSetData($tOSVI, 1, DllStructGetSize($tOSVI))
Local $aRet = DllCall('kernel32.dll', 'bool', 'GetVersionExW', 'struct*', $tOSVI)
If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0)
Return BitOR(BitShift(DllStructGetData($tOSVI, 2), -8), DllStructGetData($tOSVI, 3))
EndFunc
Func _WinAPI_GetDateFormat($iLCID = 0, $tSYSTEMTIME = 0, $iFlags = 0, $sFormat = '')
If Not $iLCID Then $iLCID = 0x0400
Local $sTypeOfFormat = 'wstr'
If Not StringStripWS($sFormat, $STR_STRIPLEADING + $STR_STRIPTRAILING) Then
$sTypeOfFormat = 'ptr'
$sFormat = 0
EndIf
Local $aRet = DllCall('kernel32.dll', 'int', 'GetDateFormatW', 'dword', $iLCID, 'dword', $iFlags, 'struct*', $tSYSTEMTIME, $sTypeOfFormat, $sFormat, 'wstr', '', 'int', 2048)
If @error Or Not $aRet[0] Then Return SetError(@error, @extended, '')
Return $aRet[5]
EndFunc
Func _WinAPI_GetLocaleInfo($iLCID, $iType)
Local $aRet = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'dword', $iLCID, 'dword', $iType, 'wstr', '', 'int', 2048)
If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '')
Return $aRet[3]
EndFunc
Func _DateDayOfWeek($iDayNum, $iFormat = Default)
Local Const $MONDAY_IS_NO1 = 128
If $iFormat = Default Then $iFormat = 0
$iDayNum = Int($iDayNum)
If $iDayNum < 1 Or $iDayNum > 7 Then Return SetError(1, 0, "")
Local $tSYSTEMTIME = DllStructCreate($tagSYSTEMTIME)
DllStructSetData($tSYSTEMTIME, "Year", BitAND($iFormat, $MONDAY_IS_NO1) ? 2007 : 2006)
DllStructSetData($tSYSTEMTIME, "Month", 1)
DllStructSetData($tSYSTEMTIME, "Day", $iDayNum)
Return _WinAPI_GetDateFormat(BitAND($iFormat, $DMW_LOCALE_LONGNAME) ? $LOCALE_USER_DEFAULT : $LOCALE_INVARIANT, $tSYSTEMTIME, 0, BitAND($iFormat, $DMW_SHORTNAME) ? "ddd" : "dddd")
EndFunc
Func _DateIsLeapYear($iYear)
If StringIsInt($iYear) Then
Select
Case Mod($iYear, 4) = 0 And Mod($iYear, 100) <> 0
Return 1
Case Mod($iYear, 400) = 0
Return 1
Case Else
Return 0
EndSelect
EndIf
Return SetError(1, 0, 0)
EndFunc
Func __DateIsMonth($iNumber)
$iNumber = Int($iNumber)
Return $iNumber >= 1 And $iNumber <= 12
EndFunc
Func _DateIsValid($sDate)
Local $asDatePart[4], $asTimePart[4]
_DateTimeSplit($sDate, $asDatePart, $asTimePart)
If Not StringIsInt($asDatePart[1]) Then Return 0
If Not StringIsInt($asDatePart[2]) Then Return 0
If Not StringIsInt($asDatePart[3]) Then Return 0
$asDatePart[1] = Int($asDatePart[1])
$asDatePart[2] = Int($asDatePart[2])
$asDatePart[3] = Int($asDatePart[3])
Local $iNumDays = _DaysInMonth($asDatePart[1])
If $asDatePart[1] < 1000 Or $asDatePart[1] > 2999 Then Return 0
If $asDatePart[2] < 1 Or $asDatePart[2] > 12 Then Return 0
If $asDatePart[3] < 1 Or $asDatePart[3] > $iNumDays[$asDatePart[2]] Then Return 0
If $asTimePart[0] < 1 Then Return 1
If $asTimePart[0] < 2 Then Return 0
If $asTimePart[0] = 2 Then $asTimePart[3] = "00"
If Not StringIsInt($asTimePart[1]) Then Return 0
If Not StringIsInt($asTimePart[2]) Then Return 0
If Not StringIsInt($asTimePart[3]) Then Return 0
$asTimePart[1] = Int($asTimePart[1])
$asTimePart[2] = Int($asTimePart[2])
$asTimePart[3] = Int($asTimePart[3])
If $asTimePart[1] < 0 Or $asTimePart[1] > 23 Then Return 0
If $asTimePart[2] < 0 Or $asTimePart[2] > 59 Then Return 0
If $asTimePart[3] < 0 Or $asTimePart[3] > 59 Then Return 0
Return 1
EndFunc
Func _DateTimeFormat($sDate, $sType)
Local $asDatePart[4], $asTimePart[4]
Local $sTempDate = "", $sTempTime = ""
Local $sAM, $sPM, $sTempString = ""
If Not _DateIsValid($sDate) Then
Return SetError(1, 0, "")
EndIf
If $sType < 0 Or $sType > 5 Or Not IsInt($sType) Then
Return SetError(2, 0, "")
EndIf
_DateTimeSplit($sDate, $asDatePart, $asTimePart)
Switch $sType
Case 0
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SSHORTDATE)
If Not @error And Not($sTempString = '') Then
$sTempDate = $sTempString
Else
$sTempDate = "M/d/yyyy"
EndIf
If $asTimePart[0] > 1 Then
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_STIMEFORMAT)
If Not @error And Not($sTempString = '') Then
$sTempTime = $sTempString
Else
$sTempTime = "h:mm:ss tt"
EndIf
EndIf
Case 1
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SLONGDATE)
If Not @error And Not($sTempString = '') Then
$sTempDate = $sTempString
Else
$sTempDate = "dddd, MMMM dd, yyyy"
EndIf
Case 2
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SSHORTDATE)
If Not @error And Not($sTempString = '') Then
$sTempDate = $sTempString
Else
$sTempDate = "M/d/yyyy"
EndIf
Case 3
If $asTimePart[0] > 1 Then
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_STIMEFORMAT)
If Not @error And Not($sTempString = '') Then
$sTempTime = $sTempString
Else
$sTempTime = "h:mm:ss tt"
EndIf
EndIf
Case 4
If $asTimePart[0] > 1 Then
$sTempTime = "hh:mm"
EndIf
Case 5
If $asTimePart[0] > 1 Then
$sTempTime = "hh:mm:ss"
EndIf
EndSwitch
If $sTempDate <> "" Then
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SDATE)
If Not @error And Not($sTempString = '') Then
$sTempDate = StringReplace($sTempDate, "/", $sTempString)
EndIf
Local $iWday = _DateToDayOfWeek($asDatePart[1], $asDatePart[2], $asDatePart[3])
$asDatePart[3] = StringRight("0" & $asDatePart[3], 2)
$asDatePart[2] = StringRight("0" & $asDatePart[2], 2)
$sTempDate = StringReplace($sTempDate, "d", "@")
$sTempDate = StringReplace($sTempDate, "m", "#")
$sTempDate = StringReplace($sTempDate, "y", "&")
$sTempDate = StringReplace($sTempDate, "@@@@", _DateDayOfWeek($iWday, 0))
$sTempDate = StringReplace($sTempDate, "@@@", _DateDayOfWeek($iWday, 1))
$sTempDate = StringReplace($sTempDate, "@@", $asDatePart[3])
$sTempDate = StringReplace($sTempDate, "@", StringReplace(StringLeft($asDatePart[3], 1), "0", "") & StringRight($asDatePart[3], 1))
$sTempDate = StringReplace($sTempDate, "####", _DateToMonth($asDatePart[2], 0))
$sTempDate = StringReplace($sTempDate, "###", _DateToMonth($asDatePart[2], 1))
$sTempDate = StringReplace($sTempDate, "##", $asDatePart[2])
$sTempDate = StringReplace($sTempDate, "#", StringReplace(StringLeft($asDatePart[2], 1), "0", "") & StringRight($asDatePart[2], 1))
$sTempDate = StringReplace($sTempDate, "&&&&", $asDatePart[1])
$sTempDate = StringReplace($sTempDate, "&&", StringRight($asDatePart[1], 2))
EndIf
If $sTempTime <> "" Then
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_S1159)
If Not @error And Not($sTempString = '') Then
$sAM = $sTempString
Else
$sAM = "AM"
EndIf
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_S2359)
If Not @error And Not($sTempString = '') Then
$sPM = $sTempString
Else
$sPM = "PM"
EndIf
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_STIME)
If Not @error And Not($sTempString = '') Then
$sTempTime = StringReplace($sTempTime, ":", $sTempString)
EndIf
If StringInStr($sTempTime, "tt") Then
If $asTimePart[1] < 12 Then
$sTempTime = StringReplace($sTempTime, "tt", $sAM)
If $asTimePart[1] = 0 Then $asTimePart[1] = 12
Else
$sTempTime = StringReplace($sTempTime, "tt", $sPM)
If $asTimePart[1] > 12 Then $asTimePart[1] = $asTimePart[1] - 12
EndIf
EndIf
$asTimePart[1] = StringRight("0" & $asTimePart[1], 2)
$asTimePart[2] = StringRight("0" & $asTimePart[2], 2)
$asTimePart[3] = StringRight("0" & $asTimePart[3], 2)
$sTempTime = StringReplace($sTempTime, "hh", StringFormat("%02d", $asTimePart[1]))
$sTempTime = StringReplace($sTempTime, "h", StringReplace(StringLeft($asTimePart[1], 1), "0", "") & StringRight($asTimePart[1], 1))
$sTempTime = StringReplace($sTempTime, "mm", StringFormat("%02d", $asTimePart[2]))
$sTempTime = StringReplace($sTempTime, "ss", StringFormat("%02d", $asTimePart[3]))
$sTempDate = StringStripWS($sTempDate & " " & $sTempTime, $STR_STRIPLEADING + $STR_STRIPTRAILING)
EndIf
Return $sTempDate
EndFunc
Func _DateTimeSplit($sDate, ByRef $asDatePart, ByRef $iTimePart)
Local $sDateTime = StringSplit($sDate, " T")
If $sDateTime[0] > 0 Then $asDatePart = StringSplit($sDateTime[1], "/-.")
If $sDateTime[0] > 1 Then
$iTimePart = StringSplit($sDateTime[2], ":")
If UBound($iTimePart) < 4 Then ReDim $iTimePart[4]
Else
Dim $iTimePart[4]
EndIf
If UBound($asDatePart) < 4 Then ReDim $asDatePart[4]
For $x = 1 To 3
If StringIsInt($asDatePart[$x]) Then
$asDatePart[$x] = Int($asDatePart[$x])
Else
$asDatePart[$x] = -1
EndIf
If StringIsInt($iTimePart[$x]) Then
$iTimePart[$x] = Int($iTimePart[$x])
Else
$iTimePart[$x] = 0
EndIf
Next
Return 1
EndFunc
Func _DateToDayOfWeek($iYear, $iMonth, $iDay)
If Not _DateIsValid($iYear & "/" & $iMonth & "/" & $iDay) Then
Return SetError(1, 0, "")
EndIf
Local $i_FactorA = Int((14 - $iMonth) / 12)
Local $i_FactorY = $iYear - $i_FactorA
Local $i_FactorM = $iMonth +(12 * $i_FactorA) - 2
Local $i_FactorD = Mod($iDay + $i_FactorY + Int($i_FactorY / 4) - Int($i_FactorY / 100) + Int($i_FactorY / 400) + Int((31 * $i_FactorM) / 12), 7)
Return $i_FactorD + 1
EndFunc
Func _DateToMonth($iMonNum, $iFormat = Default)
If $iFormat = Default Then $iFormat = 0
$iMonNum = Int($iMonNum)
If Not __DateIsMonth($iMonNum) Then Return SetError(1, 0, "")
Local $tSYSTEMTIME = DllStructCreate($tagSYSTEMTIME)
DllStructSetData($tSYSTEMTIME, "Year", @YEAR)
DllStructSetData($tSYSTEMTIME, "Month", $iMonNum)
DllStructSetData($tSYSTEMTIME, "Day", 1)
Return _WinAPI_GetDateFormat(BitAND($iFormat, $DMW_LOCALE_LONGNAME) ? $LOCALE_USER_DEFAULT : $LOCALE_INVARIANT, $tSYSTEMTIME, 0, BitAND($iFormat, $DMW_SHORTNAME) ? "MMM" : "MMMM")
EndFunc
Func _NowTime($sType = 3)
If $sType < 3 Or $sType > 5 Then $sType = 3
Return _DateTimeFormat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $sType)
EndFunc
Func _DaysInMonth($iYear)
Local $aDays[13] = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
If _DateIsLeapYear($iYear) Then $aDays[2] = 29
Return $aDays
EndFunc
Global $__g_iIELoadWaitTimeout = 300000
Global $__g_bIEAU3Debug = False
Global $__g_bIEErrorNotify = True
Global Const $__gaIEAU3VersionInfo[6] = ["T", 3, 0, 1, "20130601", "T3.0-1"]
Global Const $LSFW_LOCK = 1, $LSFW_UNLOCK = 2
Global Enum $_IESTATUS_Success = 0, $_IESTATUS_GeneralError, $_IESTATUS_ComError, $_IESTATUS_InvalidDataType, $_IESTATUS_InvalidObjectType, $_IESTATUS_InvalidValue, $_IESTATUS_LoadWaitTimeout, $_IESTATUS_NoMatch, $_IESTATUS_AccessIsDenied, $_IESTATUS_ClientDisconnected
Func _IECreate($sUrl = "about:blank", $iTryAttach = 0, $iVisible = 1, $iWait = 1, $iTakeFocus = 1)
If Not $iVisible Then $iTakeFocus = 0
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 $iMustUnlock And Not __IELockSetForegroundWindow($LSFW_UNLOCK) Then __IEConsoleWriteError("Warning", "_IECreate", "", "Foreground Window Unlock Failed!")
_IENavigate($oObject, $sUrl, $iWait)
Local $iError = @error
If Not $iError And StringLeft($sUrl, 6) = "about:" Then
Local $oDocument = $oObject.document
_IEAction($oDocument, "focus")
EndIf
Return SetError($iError, 0, $oObject)
EndFunc
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
__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
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()
Local $iTmp = 1
Local $iNotifyStatus, $bIsBrowser, $sTmp
For $oWindow In $oShellWindows
$bIsBrowser = True
$iNotifyStatus = _IEErrorNotify()
_IEErrorNotify(False)
If $bIsBrowser Then
$sTmp = $oWindow.type
If @error Then $bIsBrowser = False
EndIf
If $bIsBrowser Then
$sTmp = $oWindow.document.title
If @error Then $bIsBrowser = False
EndIf
_IEErrorNotify($iNotifyStatus)
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
__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
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
Local $iNotifyStatus = _IEErrorNotify()
_IEErrorNotify(False)
Sleep($iDelay)
Local $iError
Local $hIELoadWaitTimer = TimerInit()
If $iTimeout = -1 Then $iTimeout = $__g_iIELoadWaitTimeout
Select
Case __IEIsObjType($oObject, "browser")
While Not(String($oObject.readyState) = "complete" Or $oObject.readyState = 4 Or $bAbort)
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)
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")
While Not(String($oObject.document.readyState) = "complete" Or $oObject.document.readyState = 4 Or $bAbort)
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)
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")
$oTemp = $oObject.parentWindow
While Not(String($oTemp.document.readyState) = "complete" Or $oTemp.document.readyState = 4 Or $bAbort)
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)
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
$oTemp = $oObject.document.parentWindow
While Not(String($oTemp.document.readyState) = "complete" Or $oTemp.document.readyState = 4 Or $bAbort)
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)
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
_IEErrorNotify($iNotifyStatus)
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
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
__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)
EndFunc
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
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
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
__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)
EndFunc
Func _IEFormGetObjByName(ByRef $oObject, $sName, $iIndex = 0)
If Not IsObj($oObject) Then
__IEConsoleWriteError("Error", "_IEFormGetObjByName", "$_IESTATUS_InvalidDataType")
Return SetError($_IESTATUS_InvalidDataType, 1, 0)
EndIf
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)
EndIf
EndIf
EndFunc
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
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)
EndIf
EndIf
EndFunc
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
__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
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
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
__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
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
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
__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
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
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
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)
EndSelect
EndFunc
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)
EndIf
EndIf
EndFunc
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
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
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()
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
__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
__IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_COMError", @error)
Return SetError($_IESTATUS_ComError, @error, 0)
EndIf
$oObject = 0
Return SetError($_IESTATUS_Success, 0, 1)
Case Else
__IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_InvalidValue", "Invalid Action")
Return SetError($_IESTATUS_InvalidValue, 2, 0)
EndSelect
If @error Then
__IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_COMError", @error)
Return SetError($_IESTATUS_ComError, @error, 0)
EndIf
Return SetError($_IESTATUS_Success, 0, 1)
EndFunc
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
__IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidValue", "Invalid Property")
Return SetError($_IESTATUS_InvalidValue, 2, 0)
EndSelect
EndFunc
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
Func __IELockSetForegroundWindow($iLockCode)
Local $aRet = DllCall("user32.dll", "bool", "LockSetForegroundWindow", "uint", $iLockCode)
If @error Or Not $aRet[0] Then Return SetError(1, _WinAPI_GetLastError(), 0)
Return $aRet[0]
EndFunc
Func __IEControlGetObjFromHWND(ByRef $hWin)
DllCall("ole32.dll", "long", "CoInitialize", "ptr", 0)
If @error Then Return SetError(2, @error, 0)
Local Const $WM_HTML_GETOBJECT = __IERegisterWindowMessage("WM_HTML_GETOBJECT")
Local Const $SMTO_ABORTIFHUNG = 0x0002
Local $iResult
__IESendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 1000, $iResult)
Local $tUUID = DllStructCreate("int;short;short;byte[8]")
DllStructSetData($tUUID, 1, 0x626FC520)
DllStructSetData($tUUID, 2, 0xA41E)
DllStructSetData($tUUID, 3, 0x11CF)
DllStructSetData($tUUID, 4, 0xA7, 1)
DllStructSetData($tUUID, 4, 0x31, 2)
DllStructSetData($tUUID, 4, 0x0, 3)
DllStructSetData($tUUID, 4, 0xA0, 4)
DllStructSetData($tUUID, 4, 0xC9, 5)
DllStructSetData($tUUID, 4, 0x8, 6)
DllStructSetData($tUUID, 4, 0x26, 7)
DllStructSetData($tUUID, 4, 0x37, 8)
Local $aRet = DllCall("oleacc.dll", "long", "ObjectFromLresult", "lresult", $iResult, "struct*", $tUUID, "wparam", 0, "idispatch*", 0)
If @error Then Return SetError(3, @error, 0)
If IsObj($aRet[4]) Then
Local $oIE = $aRet[4] .Script()
Return $oIE.Document.parentwindow
Else
Return SetError(1, $aRet[0], 0)
EndIf
EndFunc
Func __IERegisterWindowMessage($sMsg)
Local $aRet = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $sMsg)
If @error Then Return SetError(@error, @extended, 0)
If $aRet[0] = 0 Then Return SetError(10, _WinAPI_GetLastError(), 0)
Return $aRet[0]
EndFunc
Func __IESendMessageTimeout($hWnd, $iMsg, $wParam, $lParam, $iFlags, $iTimeout, ByRef $vOut, $r = 0, $sT1 = "int", $sT2 = "int")
Local $aRet = DllCall("user32.dll", "lresult", "SendMessageTimeout", "hwnd", $hWnd, "uint", $iMsg, $sT1, $wParam, $sT2, $lParam, "uint", $iFlags, "uint", $iTimeout, "dword_ptr*", "")
If @error Or $aRet[0] = 0 Then
$vOut = 0
Return SetError(1, _WinAPI_GetLastError(), 0)
EndIf
$vOut = $aRet[7]
If $r >= 0 And $r <= 4 Then Return $aRet[$r]
Return $aRet
EndFunc
Func __IEIsObjType(ByRef $oObject, $sType)
If Not IsObj($oObject) Then
Return SetError($_IESTATUS_InvalidDataType, 1, 0)
EndIf
Local $iNotifyStatus = _IEErrorNotify()
_IEErrorNotify(False)
Local $sName = String(ObjName($oObject)), $iErrorStatus = $_IESTATUS_InvalidObjectType
Switch $sType
Case "browserdom"
If __IEIsObjType($oObject, "documentcontainer") Then
$iErrorStatus = $_IESTATUS_Success
ElseIf __IEIsObjType($oObject, "document") Then
$iErrorStatus = $_IESTATUS_Success
Else
Local $oTemp = $oObject.document
If __IEIsObjType($oTemp, "document") Then
$iErrorStatus = $_IESTATUS_Success
EndIf
EndIf
Case "browser"
If($sName = "IWebBrowser2") Or($sName = "IWebBrowser") Or($sName = "WebBrowser") Then $iErrorStatus = $_IESTATUS_Success
Case "window"
If $sName = "HTMLWindow2" Then $iErrorStatus = $_IESTATUS_Success
Case "documentContainer"
If __IEIsObjType($oObject, "window") Or __IEIsObjType($oObject, "browser") Then $iErrorStatus = $_IESTATUS_Success
Case "document"
If $sName = "HTMLDocument" Then $iErrorStatus = $_IESTATUS_Success
Case "table"
If $sName = "HTMLTable" Then $iErrorStatus = $_IESTATUS_Success
Case "form"
If $sName = "HTMLFormElement" Then $iErrorStatus = $_IESTATUS_Success
Case "forminputelement"
If($sName = "HTMLInputElement") Or($sName = "HTMLSelectElement") Or($sName = "HTMLTextAreaElement") Then $iErrorStatus = $_IESTATUS_Success
Case "elementcollection"
If($sName = "HTMLElementCollection") Then $iErrorStatus = $_IESTATUS_Success
Case "formselectelement"
If $sName = "HTMLSelectElement" Then $iErrorStatus = $_IESTATUS_Success
Case Else
$iErrorStatus = $_IESTATUS_InvalidValue
EndSwitch
_IEErrorNotify($iNotifyStatus)
If $iErrorStatus = $_IESTATUS_Success Then
Return SetError($_IESTATUS_Success, 0, 1)
Else
Return SetError($iErrorStatus, 1, 0)
EndIf
EndFunc
Func __IEConsoleWriteError($sSeverity, $sFunc, $sMessage = Default, $sStatus = Default)
If $__g_bIEErrorNotify Or $__g_bIEAU3Debug Then
Local $sStr = "--> IE.au3 " & $__gaIEAU3VersionInfo[5] & " " & $sSeverity & " from function " & $sFunc
If Not($sMessage = Default) Then $sStr &= ", " & $sMessage
If Not($sStatus = Default) Then $sStr &= " (" & $sStatus & ")"
ConsoleWrite($sStr & @CRLF)
EndIf
Return SetError($sStatus, 0, 1)
EndFunc
Func __IEComErrorUnrecoverable($iError)
Switch $iError
Case -2147352567
Return $_IESTATUS_AccessIsDenied
Case -2147024891
Return $_IESTATUS_AccessIsDenied
Case -2147417848
Return $_IESTATUS_ClientDisconnected
Case -2147023174
Return $_IESTATUS_ClientDisconnected
Case -2147023179
Return $_IESTATUS_ClientDisconnected
Case Else
Return $_IESTATUS_Success
EndSwitch
EndFunc
Global Const $WS_EX_TOPMOST = 0x00000008
Global Const $WM_MENUSELECT = 0x011F
Global Const $WM_MOUSEMOVE = 0x0200
Func TimerCountDown($iMilliseconds, $sGuiTitle)
Global $SS_CENTER, $_CompteArebour = $iMilliseconds, $_Minutes, $_Seconds
Global $_GuiCountDown = GUICreate($sGuiTitle, 350, 135, @DesktopWidth - 375, @DesktopHeight - 210, $WS_EX_TOPMOST)
GUISetBkColor(0xFFFF00)
$TimeLabel = GUICtrlCreateLabel("", 35, -10, 480, 180, $SS_CENTER)
GUICtrlSetFont(-1, 80, 800)
GUISetState()
WinSetOnTop($_GuiCountDown, "", 1)
Global $TimeTicks = TimerInit()
While 1
$_CompteArebour -= TimerDiff($TimeTicks)
$TimeTicks = TimerInit()
Local $_MinCalc = Int($_CompteArebour /(60 * 1000)), $_SecCalc = $_CompteArebour -($_MinCalc * 60 * 1000)
$_SecCalc = Int($_SecCalc / 1000)
If $_MinCalc <= 0 And $_SecCalc <= 0 Then
GUIDelete($_GuiCountDown)
ExitLoop
Else
If $_MinCalc <> $_Minutes Or $_SecCalc <> $_Seconds Then
$_Minutes = $_MinCalc
$_Seconds = $_SecCalc
GUICtrlSetData($TimeLabel, StringFormat("%02u" & ":" & "%02u", $_Minutes, $_Seconds))
If $_Minutes = 0 And $_Seconds <= 10 Then
GUISetBkColor(0xA093FF, $_GuiCountDown)
EndIf
EndIf
EndIf
Sleep(200)
WEnd
EndFunc
Global $wintitleBBClose = "Blackboard Learn - Internet Explorer"
Global $oIE = ""


;~ EDITED
Global $LiveOrStage = "university"
;~ EDITED

Func _bbExplorerCloseAll()
Opt("WinTitleMatchMode", 2)
Do
$wincheckBB = WinExists($wintitleBBClose)
WinClose($wintitleBBClose)
Until $wincheckBB = 0
EndFunc
Func _bbLogin()
Local $urlBBHomepage = "https://" & $LiveOrStage & ".blackboard.com/webapps/portal/execute/tabs/tabAction?tab_tab_group_id=_91_1"
Opt("WinTitleMatchMode", 2)
$wincheckBB = WinExists($wintitleBBClose)
_bbExplorerCloseAll()
Global $oIE = _IECreate($urlBBHomepage, 1, 1, 1, 1)
Local $hwndBBLogin = _IEPropertyGet($oIE, "hwnd")
Local $oForm = _IEFormGetObjByName($oIE, "login")
Local $oTextLogin = _IEFormElementGetObjByName($oForm, "user_id")
Local $oTextPass = _IEFormElementGetObjByName($oForm, "password")
_IEFormElementSetValue($oTextLogin, "USERNAME")
_IEFormElementSetValue($oTextPass, "PASSWORD")
_IEFormSubmit($oForm)
WinSetState($hwndBBLogin, "", @SW_MAXIMIZE)
EndFunc
Func BB_CourseMasterCreator_Excel($dirCourseCheckFile, $iBBSearchCategory = 0, $optDeleteCourse = 0, $optExactCopyWithTemplateName = 0, $optCheckCourseCopiedCorrectly = 0, $optDeleteAllEnrollments = 0)
Local $urlBBCourses = "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/courseManager?sourceType=COURSES"
Local $sWorkbook = $dirCourseCheckFile
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
_bbLogin()
$oWorkbook.Worksheets("CourseIDSearch").Select
$aCourseToSearch = _Excel_RangeRead($oWorkbook, Default, "A1:A10000", 1, False)
$aCourseToDelete = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
$aCourseTemplateName = _Excel_RangeRead($oWorkbook, Default, "D1:D10000", 1, False)
$aCourseExistStatus = _Excel_RangeRead($oWorkbook, Default, "F1:F10000", 1, False)
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange(0)
$CourseNameChecked = $oWorkbook.Worksheets("INI").Range("B2").Value
If $CourseNameChecked < 2 Then
For $Reconfirm = 1 To 2 Step 1
If $CourseNameChecked = 1 Then ContinueLoop
$aCourseExistStatus = _Excel_RangeRead($oWorkbook, Default, "F1:F10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseExistStatus[$i] = "Yes" Then ContinueLoop
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseExist = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseExist = 1 Then
$oWorkbook.ActiveSheet.Range("F" & $i + 1).Value = "Yes"
$oWorkbook.ActiveSheet.Range("J" & $i + 1).Value = _bbCourseReturnID($aCourseToSearch[$i])
Else
$oWorkbook.ActiveSheet.Range("F" & $i + 1).Value = "No"
$oWorkbook.ActiveSheet.Range("J" & $i + 1).Value = "-"
EndIf
_Excel_BookSave($oWorkbook)
Sleep(1000)
Next
$oWorkbook.Worksheets("INI").Range("B2").Value += 1
Next
EndIf
$aCourseToExactCopy = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $Reconfirm = 1 To 2 Step 1
$aCourseTemplateID = _Excel_RangeRead($oWorkbook, Default, "K1:K10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToExactCopy[$i] = "Yes" Then
If $aCourseToSearch[$i] = "" Then ContinueLoop
If Not $aCourseTemplateID[$i] = "" Then ContinueLoop
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange(0)
_bbCourseSearchString($aCourseTemplateName[$i])
$CheckCourseExist = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseTemplateName[$i])
If $CheckCourseExist = 1 Then
$oWorkbook.ActiveSheet.Range("K" & $i + 1).Value = _bbCourseReturnID($aCourseTemplateName[$i])
_Excel_BookSave($oWorkbook)
Else
$oWorkbook.ActiveSheet.Range("K" & $i + 1).Value = "-"
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
Next
_Excel_BookSave($oWorkbook)
If $optDeleteCourse = 1 Then
$aCourseDeletedStatus = _Excel_RangeRead($oWorkbook, Default, "G1:G10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If Not $aCourseDeletedStatus[$i] = "" Then ContinueLoop
If $aCourseExistStatus[$i] = "Yes" And $aCourseToDelete[$i] = "Yes" Then
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange(0)
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseExist = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseExist = 1 Then
$oWorkbook.ActiveSheet.Range("G" & $i + 1).Value = "Request Sent"
_bbcourse_DeleteAllFiles($aCourseToSearch[$i])
_Excel_BookSave($oWorkbook)
TimerCountDown(45000, "Deleting: " & $aCourseToSearch[$i])
Else
$oWorkbook.ActiveSheet.Range("G" & $i + 1).Value = "Request Sent"
EndIf
Else
$oWorkbook.ActiveSheet.Range("G" & $i + 1).Value = "-"
EndIf
Next
_Excel_BookSave($oWorkbook)
$aCourseDeletedStatusUpdated01 = _Excel_RangeRead($oWorkbook, Default, "G1:G10000", 1, False)
_IENavigate($oIE, $urlBBCourses, 1)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseDeletedStatusUpdated01[$i] = "Request Sent" Then
_bbCourseSearchCategoryChange(0)
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseExist = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseExist = 0 Then
$oWorkbook.ActiveSheet.Range("G" & $i + 1).Value = "Yes"
_Excel_BookSave($oWorkbook)
Else
$oWorkbook.ActiveSheet.Range("G" & $i + 1).Value = "Delete Problem"
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
EndIf
_Excel_BookSave($oWorkbook)
If $optExactCopyWithTemplateName = 1 Then
$aCourseDeletedStatusUpdated02 = _Excel_RangeRead($oWorkbook, Default, "G1:G10000", 1, False)
$aCourseExactCopyStatus00 = _Excel_RangeRead($oWorkbook, Default, "H1:H10000", 1, False)
$aCourseTemplateIDUpdate00 = _Excel_RangeRead($oWorkbook, Default, "K1:K10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If Not $aCourseExactCopyStatus00[$i] = "" Then ContinueLoop
If $aCourseToExactCopy[$i] = "Yes" Then
If $aCourseExistStatus[$i] = "No" Then
If $aCourseTemplateIDUpdate00[$i] = "-" Then ContinueLoop
_bbcourse_CopyCourse($aCourseToSearch[$i], $aCourseTemplateIDUpdate00[$i], 0)
$oWorkbook.ActiveSheet.Range("H" & $i + 1).Value = "Request Sent"
_Excel_BookSave($oWorkbook)
TimerCountDown(60000, "Paused - Course is copying...")
Else
If $aCourseDeletedStatusUpdated02[$i] = "Yes" Then
If $aCourseTemplateIDUpdate00[$i] = "-" Then ContinueLoop
$iCourseCopyStatus = _bbcourse_CopyCourse($aCourseToSearch[$i], $aCourseTemplateIDUpdate00[$i], 0)
If $iCourseCopyStatus <> 1 Then
$oWorkbook.ActiveSheet.Range("H" & $i + 1).Value = $iCourseCopyStatus
_Excel_BookSave($oWorkbook)
ContinueLoop
Else
$oWorkbook.ActiveSheet.Range("H" & $i + 1).Value = "Request Sent"
_Excel_BookSave($oWorkbook)
TimerCountDown(60000, "Paused - Course is copying...")
EndIf
Else
$oWorkbook.ActiveSheet.Range("H" & $i + 1).Value = "Request Conflict"
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Else
$oWorkbook.ActiveSheet.Range("H" & $i + 1).Value = "-"
_Excel_BookSave($oWorkbook)
EndIf
Next
_Excel_BookSave($oWorkbook)
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange(0)
For $Reconfirm = 1 To 2 Step 1
$aCourseExactCopyStatus01 = _Excel_RangeRead($oWorkbook, Default, "H1:H10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseExactCopyStatus01[$i] = "Request Sent" Or $aCourseExactCopyStatus01[$i] = "Copy Problem" Then
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseExist = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseExist = 1 Then
$oWorkbook.ActiveSheet.Range("H" & $i + 1).Value = "Yes"
$oWorkbook.ActiveSheet.Range("L" & $i + 1).Value = _bbCourseReturnID($aCourseToSearch[$i])
_Excel_BookSave($oWorkbook)
Else
$oWorkbook.ActiveSheet.Range("H" & $i + 1).Value = "Copy Problem"
$oWorkbook.ActiveSheet.Range("L" & $i + 1).Value = "-"
_Excel_BookSave($oWorkbook)
EndIf
Sleep(5000)
EndIf
Next
Next
_Excel_BookSave($oWorkbook)
EndIf
If $optCheckCourseCopiedCorrectly = 1 Then
If $optExactCopyWithTemplateName = 1 Then
Sleep(100)
$aCourseExactCopyStatus02 = _Excel_RangeRead($oWorkbook, Default, "H1:H10000", 1, False)
$aCourseNameSearchID01 = _Excel_RangeRead($oWorkbook, Default, "J1:J10000", 1, False)
$aCourseCopiedCorrectly01 = _Excel_RangeRead($oWorkbook, Default, "I1:I10000", 1, False)
$aCourseExactCopyCourseID01 = _Excel_RangeRead($oWorkbook, Default, "L1:L10000", 1, False)
$sCourseContentLinks = "Meet Your Instructor,Homepage,Syllabus,Student Resources,Program Resources,Discussion, Live!,Email,Start Here,Weeks,Gradebook,Groups,Tools,Help"
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If Not $aCourseCopiedCorrectly01[$i] = "" Then ContinueLoop
If $aCourseExactCopyStatus02[$i] = "Yes" Then
$sContentCheck = _bbCourseCopiedCorrectCheck($aCourseExactCopyCourseID01[$i], $sCourseContentLinks)
If $sContentCheck = 1 Then
$oWorkbook.ActiveSheet.Range("I" & $i + 1).Value = "Good"
_Excel_BookSave($oWorkbook)
Else
$oWorkbook.ActiveSheet.Range("I" & $i + 1).Value = $sContentCheck
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Sleep(1500)
Next
Else
$aCourseNameSearchID01 = _Excel_RangeRead($oWorkbook, Default, "J1:J10000", 1, False)
$aCourseCopiedCorrectly01 = _Excel_RangeRead($oWorkbook, Default, "I1:I10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If Not $aCourseCopiedCorrectly01[$i] = "" Then ContinueLoop
If $aCourseNameSearchID01[$i] = "-" Then
$oWorkbook.ActiveSheet.Range("I" & $i + 1).Value = "-"
_Excel_BookSave($oWorkbook)
ContinueLoop
EndIf
$sContentCheck = _bbCourseCopiedCorrectCheck($aCourseNameSearchID01[$i], $sCourseContentLinks)
If $sContentCheck = 1 Then
$oWorkbook.ActiveSheet.Range("I" & $i + 1).Value = "Good"
_Excel_BookSave($oWorkbook)
Else
$oWorkbook.ActiveSheet.Range("I" & $i + 1).Value = $sContentCheck
_Excel_BookSave($oWorkbook)
EndIf
Next
EndIf
EndIf
If $optDeleteAllEnrollments = 1 Then
$aCourseEnrollDelete = _Excel_RangeRead($oWorkbook, Default, "E1:E10000", 1, False)
$aCourseExactCopyCourseID01 = _Excel_RangeRead($oWorkbook, Default, "L1:L10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseExactCopyCourseID01[$i] = "-" Then
$oWorkbook.ActiveSheet.Range("M" & $i + 1).Value = "-"
_Excel_BookSave($oWorkbook)
ContinueLoop
EndIf
If $aCourseEnrollDelete[$i] = "Yes" Then
_bbCourseRemoveAllEnrollments($aCourseExactCopyCourseID01[$i])
$oWorkbook.ActiveSheet.Range("M" & $i + 1).Value = "Yes"
_Excel_BookSave($oWorkbook)
EndIf
Next
EndIf
MsgBox(0, "Complete", "Mission Complete!")
EndFunc
Func BB_CourseRemoveAllEnrollmentOnlyCourses($ExcelFileName)
Local $sWorkbook = $ExcelFileName
Local $urlBBCourses = "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/courseManager?sourceType=COURSES"
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
_bbLogin()
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange("Course ID")
$aCourseToSearch = _Excel_RangeRead($oWorkbook, Default, "A1:A10000", 1, False)
For $Reconfirm = 1 To 2 Step 1
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseIDs[$i] = "" Or $aCourseIDs[$i] = "Course Not Found" Then
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseFound = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseFound = 0 Then
$oWorkbook.ActiveSheet.Range("B" & $i + 1).Value = "Course Not Found"
_Excel_BookSave($oWorkbook)
Else
$ReturnCourseID = _bbCourseReturnID($aCourseToSearch[$i])
$oWorkbook.ActiveSheet.Range("B" & $i + 1).Value = $ReturnCourseID
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
Next
$aCourseNameSearchID01 = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
$aDeletedAllEnrollmentsStatus = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseNameSearchID01[$i] = "" Then
ContinueLoop
Else
If $aDeletedAllEnrollmentsStatus[$i] = "" Then
_bbCourseRemoveAllEnrollments($aCourseNameSearchID01[$i])
Sleep(1500)
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Request Sent"
EndIf
EndIf
Next
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
$CourseID = $aCourseNameSearchID01[$i]
Local $urlBBClassEnrollments = "https://-testmig.blackboard.com/webapps/blackboard/execute/courseEnrollment?sortDir=ASCENDING&showAll=true&sourceType=COURSES&editPaging=false&course_id=" & $CourseID & "&startIndex=0"
_IENavigate($oIE, $urlBBClassEnrollments, 1)
MsgBox(0, "", "1")
$CheckIfAnyUser = _bbTableDataIndexSearchString($oIE, 2, 5, "-testmig.edu")
MsgBox(0, "", "2")
If $CheckIfAnyUser = 0 Then
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Successfully deleted"
_Excel_BookSave($oWorkbook)
Else
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Not deleted"
_Excel_BookSave($oWorkbook)
EndIf
Next
MsgBox(0, "Complete", "Mission Complete")
EndFunc
Func BB_CourseRemoveAllEnrollmentOnlyOrganizations($ExcelFileName)
Local $sWorkbook = $ExcelFileName
Local $urlBBCourses = "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/courseManager?sourceType=CLUBS"
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
_bbLogin()
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange("Course ID")
$aCourseToSearch = _Excel_RangeRead($oWorkbook, Default, "A1:A10000", 1, False)
For $Reconfirm = 1 To 2 Step 1
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseIDs[$i] = "" Or $aCourseIDs[$i] = "Course Not Found" Then
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseFound = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseFound = 0 Then
$oWorkbook.ActiveSheet.Range("B" & $i + 1).Value = "Course Not Found"
_Excel_BookSave($oWorkbook)
Else
$ReturnCourseID = _bbCourseReturnID($aCourseToSearch[$i])
$oWorkbook.ActiveSheet.Range("B" & $i + 1).Value = $ReturnCourseID
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
Next
$aCourseNameSearchID01 = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
$aDeletedAllEnrollmentsStatus = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseNameSearchID01[$i] = "" Then
ContinueLoop
Else
If $aDeletedAllEnrollmentsStatus[$i] = "" Then
_bbCourseRemoveAllEnrollments($aCourseNameSearchID01[$i])
Sleep(1500)
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Request Sent"
EndIf
EndIf
Next
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
$CourseID = $aCourseNameSearchID01[$i]
Local $urlBBClassEnrollments = "https://-testmig.blackboard.com/webapps/blackboard/execute/courseEnrollment?sortDir=ASCENDING&showAll=true&sourceType=COURSES&editPaging=false&course_id=" & $CourseID & "&startIndex=0"
_IENavigate($oIE, $urlBBClassEnrollments, 1)
$CheckIfAnyUser = _bbTableDataIndexSearchString($oIE, 2, 5, "-testmig.edu")
If $CheckIfAnyUser = 0 Then
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Successfully deleted"
_Excel_BookSave($oWorkbook)
Else
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Not deleted"
_Excel_BookSave($oWorkbook)
EndIf
Next
MsgBox(0, "Complete", "Mission Complete")
EndFunc
Func BB_CourseSpecificEnrollmentRemoverCourses_Excel($dirWorkbookCourseSpecificEnrollmentDelete)
Local $urlBBCourses = "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/courseManager?sourceType=COURSES"
Local $sWorkbook = $dirWorkbookCourseSpecificEnrollmentDelete
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
_bbLogin()
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange("Course ID")
_bbCourseSearchCategoryChange("Course ID")
$aCourseToSearch = _Excel_RangeRead($oWorkbook, Default, "A1:A10000", 1, False)
$aUserNameToDelete = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
$aRemoveUsersStatus = _Excel_RangeRead($oWorkbook, Default, "D1:D10000", 1, False)
For $Reconfirm = 1 To 2 Step 1
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseIDs[$i] = "" Or $aCourseIDs[$i] = "Course Not Found" Then
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseFound = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseFound = 0 Then
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Course Not Found"
_Excel_BookSave($oWorkbook)
Else
$ReturnCourseID = _bbCourseReturnID($aCourseToSearch[$i])
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = $ReturnCourseID
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
Next
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If Not $aRemoveUsersStatus[$i] = "" Then ContinueLoop
$CourseID = $aCourseIDs[$i]
Local $urlBBClassEnrollments = "https://-testmig.blackboard.com/webapps/blackboard/execute/courseEnrollment?sortDir=ASCENDING&showAll=true&sourceType=COURSES&editPaging=false&course_id=" & $CourseID & "&startIndex=0"
_IENavigate($oIE, $urlBBClassEnrollments, 1)
If $aUserNameToDelete[$i] = "" Then
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "No Email to Search"
_Excel_BookSave($oWorkbook)
ContinueLoop
EndIf
$aMultipleEmails = StringSplit($aUserNameToDelete[$i], ",")
If @error = 1 Then
$DeletedStatus = _bbCourseRemoveSpecificEnrollment($aUserNameToDelete[$i])
Select
Case $DeletedStatus = -1
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Email Not Found"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 0
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Failed to Delete"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 1
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Delete Success"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 3
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Check box not available"
_Excel_BookSave($oWorkbook)
EndSelect
$DeletedStatus = ""
Else
For $iCount_MultEmails = 1 To UBound($aMultipleEmails) - 1 Step 1
If $aMultipleEmails[$iCount_MultEmails] = "" Then ContinueLoop
$DeletedStatus = _bbCourseRemoveSpecificEnrollment($aMultipleEmails[$iCount_MultEmails])
Select
Case $DeletedStatus = -1
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value &= "Email Not Found,"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 0
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value &= "Failed to Delete,"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 1
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value &= "Delete Success,"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 3
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Check box not available"
_Excel_BookSave($oWorkbook)
EndSelect
$DeletedStatus = ""
Next
EndIf
$CourseID = ""
Next
$aCourseToSearch = ""
$aUserNameToDelete = ""
$aCourseIDs = ""
$aRemoveUsersStatus = ""
MsgBox(0, "Complete", "Mission Complete")
EndFunc
Func BB_CourseSpecificEnrollmentRemoverOrganizations_Excel($dirWorkbookCourseSpecificEnrollmentDelete)
Local $urlBBCourses = "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/courseManager?sourceType=CLUBS"
Local $sWorkbook = $dirWorkbookCourseSpecificEnrollmentDelete
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
_bbLogin()
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange("Course ID")
_bbCourseSearchCategoryChange("Course ID")
$aCourseToSearch = _Excel_RangeRead($oWorkbook, Default, "A1:A10000", 1, False)
$aUserNameToDelete = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
$aRemoveUsersStatus = _Excel_RangeRead($oWorkbook, Default, "D1:D10000", 1, False)
For $Reconfirm = 1 To 2 Step 1
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseIDs[$i] = "" Or $aCourseIDs[$i] = "Course Not Found" Then
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseFound = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseFound = 0 Then
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Course Not Found"
_Excel_BookSave($oWorkbook)
Else
$ReturnCourseID = _bbCourseReturnID($aCourseToSearch[$i])
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = $ReturnCourseID
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
Next
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If Not $aRemoveUsersStatus[$i] = "" Then ContinueLoop
$CourseID = $aCourseIDs[$i]
Local $urlBBClassEnrollments = "https://-testmig.blackboard.com/webapps/blackboard/execute/courseEnrollment?sortDir=ASCENDING&showAll=true&sourceType=COURSES&editPaging=false&course_id=" & $CourseID & "&startIndex=0"
Sleep(2000)
_IENavigate($oIE, $urlBBClassEnrollments, 1)
Sleep(2000)
If $aUserNameToDelete[$i] = "" Then
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "No Email to Search"
_Excel_BookSave($oWorkbook)
ContinueLoop
EndIf
$aMultipleEmails = StringSplit($aUserNameToDelete[$i], ",")
If @error = 1 Then
$DeletedStatus = _bbCourseRemoveSpecificEnrollment($aUserNameToDelete[$i])
Select
Case $DeletedStatus = -1
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Email Not Found"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 0
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Failed to Delete"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 1
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Delete Success"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 3
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Check box not available"
_Excel_BookSave($oWorkbook)
EndSelect
$DeletedStatus = ""
Else
For $iCount_MultEmails = 1 To UBound($aMultipleEmails) - 1 Step 1
If $aMultipleEmails[$iCount_MultEmails] = "" Then ContinueLoop
$DeletedStatus = _bbCourseRemoveSpecificEnrollment($aMultipleEmails[$iCount_MultEmails])
Select
Case $DeletedStatus = -1
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value &= "Email Not Found,"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 0
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value &= "Failed to Delete,"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 1
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value &= "Delete Success,"
_Excel_BookSave($oWorkbook)
Case $DeletedStatus = 3
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Check box not available"
_Excel_BookSave($oWorkbook)
EndSelect
$DeletedStatus = ""
Next
EndIf
$CourseID = ""
Next
$aCourseToSearch = ""
$aUserNameToDelete = ""
$aCourseIDs = ""
$aRemoveUsersStatus = ""
MsgBox(0, "Complete", "Mission Complete")
EndFunc
Func BB_CleanSISLogs()
_bbLogin()
_IENavigate($oIE, "https://-testmig.blackboard.com/webapps/dataIntegration/execute/dataIntegration/logManager", 1)
Local $loop = 1
Do
Local $iErrors = ""
Local $iWarnings = ""
Local $iMessages = ""
Local $iDebug = ""
Local $sTxt = ""
Local $oLinks = _IETagNameGetCollection($oIE, "li")
For $oLink In $oLinks
$sTxt &= $oLink.innertext & @CRLF
Next
$iErrors = StringInStr($sTxt, "0 Errors")
$iWarnings = StringInStr($sTxt, "0 Warnings")
$iMessages = StringInStr($sTxt, "0 Messages")
$iDebug = StringInStr($sTxt, "0 Debug Items")
$ZeroMsgs = $iErrors = 0 Or $iWarnings = 0 Or $iMessages = 0 Or $iDebug = 0
If $ZeroMsgs = True Then
_IENavigate($oIE, "javascript:logManager.clearLog();", 0)
Sleep(500)
ControlClick("Message from webpage", "", "[CLASS:Button; INSTANCE:1]", "left", 1)
_IELoadWait($oIE)
Sleep(1000)
Else
$loop = 0
MsgBox(0, "Clear SIS Log", "SIS log cleared.")
EndIf
Until $loop = 0
EndFunc
Func BB_OnlyCheckCourseLinks($dirWorkbookCourseLinks)
Local $urlBBCourses = "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/courseManager?sourceType=COURSES"
Local $sWorkbook = $dirWorkbookCourseLinks
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
_bbLogin()
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange("Course ID")
_bbCourseSearchCategoryChange("Course ID")
$aCourseToSearch = _Excel_RangeRead($oWorkbook, Default, "A1:A10000", 1, False)
For $Reconfirm = 1 To 2 Step 1
Sleep(1000)
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseIDs[$i] = "" Or $aCourseIDs[$i] = "Course Not Found" Then
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseFound = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseFound = 0 Then
$oWorkbook.ActiveSheet.Range("B" & $i + 1).Value = "Course Not Found"
_Excel_BookSave($oWorkbook)
Else
$ReturnCourseID = _bbCourseReturnID($aCourseToSearch[$i])
$oWorkbook.ActiveSheet.Range("B" & $i + 1).Value = $ReturnCourseID
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
Next
$sWeeks = ""
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
$aCourseCopiedCorrectly01 = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
Sleep(1500)
If $aCourseToSearch[$i] = "" Then ContinueLoop
If Not $aCourseCopiedCorrectly01[$i] = "" Then ContinueLoop
$sContentCheck = _bbCourseLinksCapture($aCourseIDs[$i])
$iTempSearchResult = _ArrayFindAll($sContentCheck, "Week", 0, 0, 0, 1)
If $iTempSearchResult = -1 Then
$iTempSearchResult = _ArrayFindAll($sContentCheck, "Semana", 0, 0, 0, 1)
EndIf
For $ii = 0 To UBound($iTempSearchResult) - 1 Step 1
If StringLen($sContentCheck[$iTempSearchResult[$ii]]) <= 9 Then
$sWeeks &= $sContentCheck[$iTempSearchResult[$ii]] & ","
EndIf
Next
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = $sWeeks
_Excel_BookSave($oWorkbook)
$sWeeks = ""
Next
MsgBox(0, "Complete", "Mission Complete")
EndFunc
Func _bbCourseLinksCapture($CourseID)
Local $urlBBCourseContent = "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/modulepage/view?course_id=" & $CourseID
If $CourseID = "" Then Exit MsgBox(0, "", "Need search value")
_IENavigate($oIE, $urlBBCourseContent, 1)
Local $aGetLinks[0]
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
_ArrayAdd($aGetLinks, $iNumLinks & " links found")
For $oLink In $oLinks
_ArrayAdd($aGetLinks, $oLink.innertext)
Next
Return $aGetLinks
EndFunc
Func BB_CourseJustView($dirWorkbookCourseJustView)
Local $urlBBCourses = "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/courseManager?sourceType=COURSES"
Local $sWorkbook = $dirWorkbookCourseJustView
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
_bbLogin()
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange("Course ID")
_bbCourseSearchCategoryChange("Course ID")
$aCourseToSearch = _Excel_RangeRead($oWorkbook, Default, "A1:A10000", 1, False)
For $Reconfirm = 1 To 2 Step 1
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseIDs[$i] = "" Or $aCourseIDs[$i] = "Course Not Found" Then
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseFound = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseFound = 0 Then
$oWorkbook.ActiveSheet.Range("B" & $i + 1).Value = "Course Not Found"
_Excel_BookSave($oWorkbook)
Else
$ReturnCourseID = _bbCourseReturnID($aCourseToSearch[$i])
$oWorkbook.ActiveSheet.Range("B" & $i + 1).Value = $ReturnCourseID
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
Next
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
$aCourseViewed = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseIDs[$i] = "" Or $aCourseViewed[$i] = "Yes" Then ContinueLoop
_IENavigate($oIE, "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/modulepage/view?course_id=" & $aCourseIDs[$i], 1)
$YorN = MsgBox($MB_YESNO, "", "Course looks good?")
If $YorN = $IDYES Then
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Yes"
_Excel_BookSave($oWorkbook)
Else
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "No"
_Excel_BookSave($oWorkbook)
EndIf
Next
MsgBox(0, "Complete", "Mission Complete")
EndFunc
Func Course_CopyIntoExisting($dirWorkbookCopyIntoExisting)
Local $urlExistingCopyTemplate = "https://-testmig.blackboard.com/webapps/blackboard/execute/copy_content?navItem=copy_course_content_exists&target=yes&type=course&exist_course_id="
Local $urlBBCourses = "https://" & $LiveOrStage & ".blackboard.com/webapps/blackboard/execute/courseManager?sourceType=COURSES"
Local $sWorkbook = $dirWorkbookCopyIntoExisting
Local $oAppl = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
_bbLogin()
_IENavigate($oIE, $urlBBCourses, 1)
_bbCourseSearchCategoryChange("Course ID")
_bbCourseSearchCategoryChange("Course ID")
$aCourseToSearch = _Excel_RangeRead($oWorkbook, Default, "A1:A10000", 1, False)
For $Reconfirm = 1 To 2 Step 1
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCourseIDs[$i] = "" Or $aCourseIDs[$i] = "Course Not Found" Then
_bbCourseSearchString($aCourseToSearch[$i])
$CheckCourseFound = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseToSearch[$i])
If $CheckCourseFound = 0 Then
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = "Course Not Found"
_Excel_BookSave($oWorkbook)
Else
$ReturnCourseID = _bbCourseReturnID($aCourseToSearch[$i])
$oWorkbook.ActiveSheet.Range("C" & $i + 1).Value = $ReturnCourseID
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
Next
$aCourseTemplateName = _Excel_RangeRead($oWorkbook, Default, "B1:B10000", 1, False)
For $Reconfirm = 1 To 2 Step 1
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "D1:D10000", 1, False)
For $i = 1 To UBound($aCourseTemplateName) - 1 Step 1
If $aCourseTemplateName[$i] = "" Then ContinueLoop
If $aCourseIDs[$i] = "" Or $aCourseIDs[$i] = "Course Not Found" Then
_bbCourseSearchString($aCourseTemplateName[$i])
$CheckCourseFound = _bbTableDataIndexSearch($oIE, 2, 2, $aCourseTemplateName[$i])
If $CheckCourseFound = 0 Then
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = "Course Not Found"
_Excel_BookSave($oWorkbook)
Else
$ReturnCourseID = _bbCourseReturnID($aCourseTemplateName[$i])
$oWorkbook.ActiveSheet.Range("D" & $i + 1).Value = $ReturnCourseID
_Excel_BookSave($oWorkbook)
EndIf
EndIf
Next
Next
$aCourseIDs = _Excel_RangeRead($oWorkbook, Default, "C1:C10000", 1, False)
$aTemplateIDs = _Excel_RangeRead($oWorkbook, Default, "D1:D10000", 1, False)
$aCopied = _Excel_RangeRead($oWorkbook, Default, "E1:E10000", 1, False)
For $i = 1 To UBound($aCourseToSearch) - 1 Step 1
If $aCourseToSearch[$i] = "" Then ContinueLoop
If $aCopied[$i] = "Yes" Then ContinueLoop
_IENavigate($oIE, $urlExistingCopyTemplate & $aTemplateIDs[$i], 1)
$oCourseDestinationID = _IEGetObjByName($oIE, "destinationCourseId")
_IEAction($oCourseDestinationID, "focus")
_IEFormElementSetValue($oCourseDestinationID, $aCourseToSearch[$i], 1