Terminology

_IEDocReadHTML(<object>) Returns the full HTML source of a document object from Internet Explorer.

_IEGetObjById($oObject,$sID) Returns the object with id $sID from parent object $oObject.

_IELoadWait Internet Explorer: Wait for a browser page load to complete before returning.

_IETableGetCollection Returns a collection object variable representing all the tables in a document or a single table by index.

_INetGetSource($url) Get the source from a URL without writing a temp file.

StringRegExp(<subject>,<pattern>,<flag>,<offset>) Check if a string fits a given regular expression pattern.

StringSplit(<string>,<delimiters>,<flag>) Splits up a string into substrings depending on the given delimiters.

Facts, Thoughts and Opinions

Dump a <table> element to console

  Assumes that the table contains no nested <table>s.

Func DumpTable($oTable)

   Local $cTr = $oTable.querySelectorAll("tr")
   Local $trIndex = 0
   For $oTr in $cTr

       Local $cTd = $oTr.querySelectorAll("td")
       Local $tdIndex = 0
       For $oTd in $cTd
           ConsoleWrite($trIndex & "," & $tdIndex & ": " & $oTd.outerHtml & @CRLF)
           $tdIndex += 1
       Next

       $trIndex += 1
   Next
EndFunc

DumpNode

Func DumpNode($node)
   Local $count = 0
   For $child in $node.childNodes
      ConsoleWrite("[" & $count & "]: " & $child.outerHtml & @CRLF)
      $count += 1
   Next
EndFunc

SavePageAsHTML

Func SavePageAsHTML(ByRef $oIE, $outFilePath)
   $file = FileOpen($outFilePath, $FO_OVERWRITE)
   FileWrite($file,_IEDocReadHTML($oIE))
   FileClose($file)
   ConsoleWrite("Saved as " & $outFilePath & "." & @CRLF)
EndFunc

SaveSentFile

A function for saving a file sent to IE with a particular filename. Supports only the case where IE opens up the "save file" ribbon.

Func SaveSentFile($filename)

   Send("!n{TAB}{DOWN}{DOWN}{ENTER}") ; Navigate to save/open ribbon -> Save -> Save As
   Sleep(2000) ; Wait for Save dialog to appear.

   Send($fileName) ; Enter the full file path in the Save dialog.
   Send("{ENTER}") ; Submit it.
   Sleep(2000) ; Wait for save to finish.

   Send("!n{ESC}") ; Close ribbon (save/open ribbon -> [X])

EndFunc

Images

[[/div]]
  •   Subtopics

  •   Writings

  Sources & Bookmarks