#include #include #Include #include #include #include #include #include #include #include "CUIAutomation2.au3" #include "UIAWrappers.au3" ;Open the Excel Book and copy its contents into an array Local $sWorkbook = "C:\YOUR FILE DIRECTORY HERE\UAL Responses.xls" Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) $oWorkbook = _Excel_BookAttach($sWorkbook) Global $result = ReadSheet($oWorkbook, "Sheet1") ;Close the workbook _Excel_BookClose($oWorkbook, False) ;Open the Chrome Browser and go to the defined webpage $oChrome = ShellExecuteWait("chrome.exe", "YOUR WEB ADDRESS HERE","","","") ;Waits for login credentials (if any) $MyBox = 0 While $MyBox <> 6 Sleep(7000) $MyBox = MsgBox ( $MB_YESNOCANCEL, "Are You Logged Into AiM?", "Click Yes to start loading records." & @CRLF & "Click No For more time to login." & @CRLF & "Click Cancel to Quit." ) If $MyBox == 2 Then MsgBox(0,"Message Box Title","The Script has been cancelled") Exit EndIf WEnd ;Just to be sure, sets focus on the page $oChrome=_UIA_getFirstObjectOfElement($UIA_oDesktop,"Title:=Universal Action List - Google Chrome", $treescope_children) ;Change this to the title of our webpage $oChrome.setfocus() If Not IsObj($oChrome) Then ConsoleWrite("Sorry no Chrome object found") EndIf ;Enters the Edit hotkey to go the edittable form - likely not useful unless you are using AiM Send("!+E") Sleep(1000) ;Clicks the Address Bar $oChromeAddressBar=_UIA_getFirstObjectOfElement($oChrome,"Title:=Address and search bar" , $treescope_subtree) ;You may need to change your address bar title - use simpleSpy to find it _UIA_action($oChromeAddressBar, "leftclick") ;gets the row number of the last record in Excel $resultLength = UBound($result) ;loops through the Excel records and keys the result of row{n} column{7} into each consecutive row in the web form Local $n = 1 Local $z = $n-1 While $n < $resultLength Dim $Response = $result[$n][7] ;types javascript into the address bar that enters the data into the appropriate row on the form $myText=("javascript:{{}var div = document.getElementById('mainForm:UAL_EDIT_content:actionItemsBrowse:" & $z & ":response');div.innerHTML =""" & $Response & """;void(0);{}}{ENTER}") _UIA_action($oChromeAddressBar, "setvalue using keys", $myText) Sleep(500) ;needed to reset focus on the address bar _UIA_action($oChromeAddressBar, "leftclick") Sleep(500) $n = $n + 1 $z = $z + 1 WEnd ;Excel Functions - adapted from Rarst.net Func _StringCount($string, $substring) ;Counting function used to count # of columns Local $i, $count = 0 For $i = 1 To StringLen($string) If StringMid($string, $i, StringLen($substring)) = $substring Then $count = $count + 1 EndIf Next Return $count EndFunc ;==>_StringCount Func ExcelSheetToClip($excel, $sheet) ;simply copies all contents of a worksheet $excel.Sheets($sheet).Activate ClipPut("") ;empties the clipboard Sleep(10) Send("^a^c") ;selects all and copies Do Sleep(100) Until ClipGet() Return ClipGet() EndFunc ;==>ExcelSheetToClip Func String2DSplit($string, $rowDelimiter = @CRLF, $columnDelimiter = " ") ;splits the wall of text copied from ExcelSheetToClip into an array of each cell's contents by the row delimeter and column delimeter $lines = StringSplit(StringStripWS($string, 3), $rowDelimiter, 1) $columnsNum = _StringCount($lines[1], $columnDelimiter) + 1 ;NOTE! all rows must have the same number of columns as row 1! Dim $result[$lines[0]][$columnsNum] = [[0]] For $i = 1 To $lines[0] $columns = StringSplit($lines[$i], $columnDelimiter) For $j = 1 To $columns[0] $result[$i - 1][$j - 1] = $columns[$j] Next Next Return $result EndFunc ;==>String2DSplit Func ReadSheet($excel, $sheet) ;Wrapper function Return String2DSplit(ExcelSheetToClip($excel, $sheet)) EndFunc ;==>ReadSheet