dar100111 Posted May 26, 2015 Posted May 26, 2015 Hey Everyone!It's been a while so I'm not current on any IE function issues at this time (if there are any).I have had a script working well for a year now and for some reason the _IELoadWait just isn't going to work for me on a website that I'm booking shipments on out of a sql query I'm running out of our system.I'm basically have an issue now with this site where I need to be able to wait until I'm getting a certain element on the next page after clicking on the submit button. I'll have to find a way to get through a few screens and was trying the below, only it's not really working like I'd thought it would. If I put a sleep(5000) after the first _ieloadwait then the page might actually have the table I want up where I'm recognizing that a date of what I'm previously entering in matches it, therefore noting I'm at the right spot now. However if that sleep isn't in there, I just keep getting the wrong table index because it's read the old index and for some reason just doesn't update after that. For somereason my code just keeps pulling the wrong table if I don't put that sleep in there. I would think it would refresh every time to finally pull the right table. Is there a way to make sure that this _ieTableGetCollection($oiE, 8) updates. I've tried deleting it but nothing seems to work. It just gets stuck in the loop. If I uncomment the ;Sleep(5000) works fine though. Thanks for the help! _IEAction($continue, "click") _IELoadWait($oIE) ;Sleep(5000) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;On Shipment info Screen Do $fwtender = "" $oIE = _IEAttach("Forward") $onlineshipping = _IEFormGetObjByName($oIE, "onlineShipping") $fwdntable = _IETableGetCollection($oIE, 8) $fwdnarray = _IETableWriteToArray($fwdntable, True) If IsArray($fwdnarray) then _ArrayDisplay($fwdnarray) If IsArray($fwdnarray) and UBound($fwdnarray, 1) > 4 and UBound($fwdnarray, 2) > 1 then $fwtender = StringStripWS($fwdnarray[4][1], 3) If IsArray($fwdnarray) and UBound($fwdnarray, 1) > 4 and UBound($fwdnarray, 2) > 1 then $fweta = StringStripWS($fwdnarray[5][1], 3) ConsoleWrite(@lf & "waiting on eta to match") Sleep(2000) Until $fwtender = $date
dar100111 Posted May 27, 2015 Author Posted May 27, 2015 (edited) The deeper i dig the more this baffles me. The ;Sleep(5000) uncommented is actually not helping. I have to actually put a MsgBox and wait until the Screen gets to the other screen for it to pull the below correctly. Even if I put a Sleep(10000) and it has loaded the new screen before the screen expires. It still pulls the table from the other page. I've also created the $oIE instance already previously in the code but I have to attach it again, or else it won't find any of the variables on some of these pages after they have loaded.$fwdntable = _IETableGetCollection($oIE, 8)Pasting more code if anyone can see anything that might be causing the interference. I'm kicking it off through a gui off of the click on this $bookbutton.This was my first AutoIT script, hope you don't judge too harshly and thanks for anyone with suggestions. expandcollapse popup#include <IE.au3> #include <Excel.au3> #include <Array.au3> #include <Clipboard.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $filelocation = @ScriptDir & "\" $sqlquerybase = "SELECT SH.CONSOL_REF ,OH.SHPMNT_REF ,OH.ONHAND_REF ,INT(OI.PCS),INT(OI.LENGTH_2 / 254),INT(OI.WIDTH_2 / 254),INT(OI.HEIGHT_2 / 254),TRIM(CH.PORT_ORIGIN),TRIM(CH.PORT_DESTIN),CH.UOM_DIM ,CH.PCS_GRS ,INT(CH.WGT_GRS_1 *.000220462) FROM EXPORT.SHPMNT_HDR SH LEFT JOIN EXPORT.ONHAND_HDR OH ON SH.SHPMNT_REF = OH.SHPMNT_REF LEFT JOIN EXPORT.ONHAND_ITEM OI ON OH.ONHAND_REF = OI.ONHAND_REF LEFT JOIN EXPORT.CONSOL_HDR CH ON CH.CONSOL_REF = SH.CONSOL_REF WHERE SH.CONSOL_REF IN (" ;;;;;;Gui Creation GUICreate("FWDN Tool", 190, 280) GUICtrlCreateLabel("Forward Air Tool Actions", 30, 20) $systeminfobutton = GUICtrlCreateButton("Get System Info", 10, 50, 170) $bookbutton = GUICtrlCreateButton("Book Shipments on Forward Air", 10, 80, 170) $linkbutton = GUICtrlCreateButton("Link FWDN Refs in Export", 10, 110, 170) $trackbutton = GUICtrlCreateButton("Track Forward Air Bills", 10, 140, 170) $opentool = GUICtrlCreateButton("Open Excel Tool", 10, 170, 170) $setuptool = GUICtrlCreateButton("User Setup", 10, 200, 170) $AboutMenu = GUICtrlCreateMenu("&About") $AboutItem = GUICtrlCreateMenuItem("This Program is not intended for Complete Shipments!", $AboutMenu) GUISetState(@SW_SHOW) Func _IEErrorNotify_ON_OFF() If _IEErrorNotify() Then MsgBox($MB_SYSTEMMODAL, "_IEErrorNotify Status", "Notification is ON, turning it OFF") ConsoleWrite('> Turning _IEErrorNotify OFF' & @CRLF) _IEErrorNotify(False) Else MsgBox($MB_SYSTEMMODAL, "_IEErrorNotify Status", "Notification is OFF, turning it ON") ConsoleWrite('> Turning _IEErrorNotify ON' & @CRLF) _IEErrorNotify(True) EndIf EndFunc ;==>_IEErrorNotify_ON_OFF Func _pause() Do Sleep(100) Until StringInStr(ControlGetText($exportwindow,"", "[CLASS:TStatusBar; INSTANCE:1]"), "Ready") EndFunc Func _abandonchange() If StringInStr(ControlGetText($exportwindow,"", "[CLASS:TEIMemo; INSTANCE:1]"), "will be lost") Then ControlSend($exportwindow,"","TScrollBox1","{F2}") _pause() EndIf EndFunc Func _changeevent() If StringInStr(ControlGetText($exportwindow,"", "[CLASS:TEIMemo; INSTANCE:1]"), "reason code is required") Then ControlSetText($exportwindow, "", "[CLASS:TEIEdit; INSTANCE:2]", "DE") ControlSend($exportwindow,"","TScrollBox1","{F1}") _pause() ControlSend($exportwindow,"","TScrollBox1","{F1}") _pause() EndIf EndFunc Func LoadSQLFile($p_FilePath) Local $l_strFinal, $l_File $l_File = FileOpen($p_FilePath, 0) $l_strFinal = FileRead($l_File) FileClose($l_File) return $l_strFinal EndFunc Func _WaitOnForm($_form_name) Do Local $xIE = _IEAttach("Forward") Local $xForm = _IEFormGetObjByName($xIE, $_form_name) ConsoleWrite(@lf & "waiting on " & $_form_name & " form to appear") Sleep(2000) Until IsObj($xForm) EndFunc Func _WaitOnForm2($_form_name) Do Sleep(10000) Local $zIE = _IEAttach("Forward") Local $zForm = _IEFormGetObjByName($zIE, $_form_name) ConsoleWrite(@lf & "waiting on " & $_form_name & " form to appear") Until IsObj($zForm) EndFunc Func ConnectToETMS($p_branch, $p_user, $p_password) Local $l_objConn $l_objConn = ObjCreate("ADODB.Connection") if @error = 1 then return '' $l_objConn.Open("DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME=" & $p_branch & "." & $p_branch & ".ei;PORT=50000;DATABASE=" & $p_branch & ";PROTOCOL=TCPIP;UID=" & $p_user & ";PWD=" & $p_password) if $l_objConn.State = 0 then return '' return $l_objConn EndFunc Func QueryToArray($p_connection, $p_query) Local $i, $j, $l_objQuery, $l_result $l_objQuery = ObjCreate("ADODB.Recordset") if @error = 1 then return '' $l_objQuery.Open($p_query, $p_connection) if $l_objQuery.State = 0 then return '' Dim $l_result[1][$l_objQuery.Fields.Count] For $j = 0 to $l_objQuery.Fields.Count - 1 $l_result[0][$j] = $l_objQuery.Fields($j).Name Next $i = 1 if $l_objQuery.EOF then return $l_result Do For $j = 0 To $l_objQuery.Fields.Count - 1 if $i < UBound($l_result) Then $l_result[$i][$j] = $l_objQuery.Fields.Item($j).value Else ReDim $l_result[Ubound($l_result, 1) + 1][$l_objQuery.Fields.Count] $l_result[$i][$j] = $l_objQuery.Fields.Item($j).value EndIf Next $l_objQuery.MoveNext $i = $i + 1 Until $l_objQuery.EOF return $l_result EndFunc Func CloseConnection($p_connection) Return $p_connection.Close EndFunc While 1 Switch GUIGetMsg() Case $systeminfobutton ;;Get System information from database $oAppl = _Excel_Open() $oExcel = _Excel_BookOpen($oAppl, $filelocation & "bulkbook.xlsm") Global $inputsarray = _Excel_RangeRead($oExcel) ;_ArrayDisplay($inputsarray) TrayTip("Script", "Opening Bulkbook.", 10) $serverbranch = _Excel_RangeRead($oExcel, "Input", "Q2") TrayTip("Script", "Reading Consols from sheet.", 10) $counter = UBound($inputsarray, 1) - 2 ;MsgBox("","",$counter) Global $excelstartrow = 2 Global $endsqlquery = "" Global $front = "'" Global $back = "'," For $i = 1 to $counter Step 1 $consol = $inputsarray[$excelstartrow][0] If $consol <> '' Then $endsqlquery = $endsqlquery & $front & $consol & $back EndIf $excelstartrow = $excelstartrow + 1 Next $endsqlquery = StringTrimRight($endsqlquery, 1) ;;;connecting to ETMS to run dims query TrayTip("Script", "Connecting to database.", 10) $oConn = ConnectToETMS($serverbranch, 'DBGUEST', 'EXPDWASH') $query = $sqlquerybase & $endsqlquery & ")" TrayTip("Script", "Executing query.", 10) $results = QueryToArray($oConn, $query) CloseConnection($oConn) ;_ArrayDisplay($results) ;;;array manipulation to enter all instances into a row by pcs, len, wid, hgt for each onhand $counter = UBound($inputsarray, 1) - 2 $excelstartrow = 2 For $x = 1 to $counter ;_ArrayDisplay($inputsarray) $currentconsol = $inputsarray[$excelstartrow][0] ;MsgBox("", "", "Current consol " & $currentconsol & " on row " & $excelstartrow) $found = _ArrayFindAll($results, $currentconsol, 0, 0, 0, 1) $searchcount = UBound($found) $foundstart = 0 $pcsstart = 22 $lenstart = 23 $widstart = 24 $hgtstart = 25 For $i = 1 To $searchcount Step 1 $searchrow = $found[$foundstart] $pcs = $results[$searchrow][3] $len = $results[$searchrow][4] If $len = 0 Then $len = 20 $wid = $results[$searchrow][5] If $wid = 0 Then $wid = 20 $hgt = $results[$searchrow][6] If $hgt = 0 Then $hgt = 20 $PCol = _Excel_ColumnToLetter($pcsstart) & $excelstartrow+1 _Excel_RangeWrite($oExcel, "Input", $pcs, _Excel_ColumnToLetter($pcsstart) & $excelstartrow+1) _Excel_RangeWrite($oExcel, "Input", $len, _Excel_ColumnToLetter($lenstart) & $excelstartrow+1) _Excel_RangeWrite($oExcel, "Input", $wid, _Excel_ColumnToLetter($widstart) & $excelstartrow+1) _Excel_RangeWrite($oExcel, "Input", $hgt, _Excel_ColumnToLetter($hgtstart) & $excelstartrow+1) ;_ExcelWriteCell($oExcel, $len, $excelstartrow, $lenstart) ;_ExcelWriteCell($oExcel, $wid, $excelstartrow, $widstart) ;_ExcelWriteCell($oExcel, $hgt, $excelstartrow, $hgtstart) $foundstart = $foundstart + 1 $pcsstart = $pcsstart + 4 $lenstart = $lenstart + 4 $widstart = $widstart + 4 $hgtstart = $hgtstart + 4 Next $origin = $results[$searchrow][7] $destin = $results[$searchrow][8] $totalpcs = $results[$searchrow][10] $consol_act_wgt = $results[$searchrow][11] _Excel_RangeWrite($oExcel, "Input", $consol_act_wgt, "B" & $excelstartrow+1) _Excel_RangeWrite($oExcel, "Input", $totalpcs, "C" & $excelstartrow+1) _Excel_RangeWrite($oExcel, "Input", $origin, "D" & $excelstartrow+1) _Excel_RangeWrite($oExcel, "Input", $destin, "E" & $excelstartrow+1) _Excel_RangeWrite($oExcel, "Input", "FREIGHT ALL KINDS", "F" & $excelstartrow+1) Next MsgBox("Consol Dim Completion", "Consol Information Entered", "Complete!") Case $bookbutton ;;Book Shipments on Web $row = 2; setting starting row in excel document to start at same point in array $webuser = InputBox("Forward Air Bulk Book Script", @LF & @LF &" ENTER WEBSITE USERNAME") If @error = 1 Then Exit ; Cancel button pressed $webpw = InputBox("Forward Air Bulk Book Script",@LF & @LF & " ENTER Password") If @error = 1 Then Exit ; Cancel button pressed Do $date = InputBox("Forward Air Bulk Book Script", @lf & " ENTER date booking freight" & @LF & @LF & " ENTER in mm/dd/yyyy format") If @error = 1 Then Exit ; Cancel button pressed Until StringLen($date) = 10 $oAppl = _Excel_Open() $oExcel = _Excel_BookOpen($oAppl, $filelocation & "bulkbook.xlsm") $aArray = _Excel_RangeRead($oExcel, "Input") $currentbranch = $aArray[1][16] $counter = UBound($aArray, 1) $columnstop = UBound($aArray, 2) ReDim $aArray[$counter][$columnstop + 5] $first = $aArray[1][17] $last = $aArray[1][18] $user = $first & " " & $last $uphone = $aArray[1][20] $uemail = $aArray[1][19] Global $oIE = _IECreate("http://forwardair.com",0,1,1) $oForm = _IEFormGetObjByName($oIE, "loginForm");enter the form id or name $uname = _IEFormElementGetObjByName($oForm, "UserName") $pw = _IEFormElementGetObjByName($oForm, "Password") _IEFormElementSetValue($uname, $webuser);;;;;ENTER PASSWORD _IEFormElementSetValue($pw, $webpw) $login = _IEGetObjByName($oIE,"B1") _IEAction($login, "click") _IELoadWait($oIE);this is wait is actually working properly Do _IENavigate($oIE, "http://forwardair.com/servlet/fwrd.unix.servlet.StartOnlineShippingServlet"); If I tell it to wait while navigating, the script will actually get stuck right here for some reason _WaitOnForm("onlineShipping") $floating_plt = 21 $floating_L = 22 $floating_W = 23 $floating_H = 24 ;;SET VARIABLE FROM EXCEL ARRAY $eiref = $aArray[$row][0] $pcs = $aArray[$row][2] $wgt = $aArray[$row][1] $origin = $aArray[$row][3] $dest = $aArray[$row][4] $type = $aArray[$row][5] $special = $aArray[$row][7] ;;variables set from current row in excel book $oIE = _IEAttach("Forward") $shipForm = _IEFormGetObjByName($oIE, "onlineShipping") $forg = _IEFormElementGetObjByName($shipForm, "origin") $fdest = _IEFormElementGetObjByName($shipForm, "destination") $goods = _IEFormElementGetObjByName($shipForm, "desc0") $shipdate = _IEFormElementGetObjByName($shipForm, "shipmentDate1") $fpieces = _IEFormElementGetObjByName($shipForm, "pcs0") $fwgt = _IEFormElementGetObjByName($shipForm, "wgt0") $ref1 = _IEFormElementGetObjByName($shipForm, "referenceNumber_0") $instr = _IEFormElementGetObjByName($shipForm, "instructions") $continue = _IEGetObjByName($shipForm, "B1"); Continue button _IEFormElementSetValue($shipdate, $date) _IEFormElementOptionSelect($forg, $origin, 1, "byValue") _IEFormElementOptionSelect($fdest, $dest, 1, "byValue") _IEFormElementSetValue($fpieces, $pcs) _IEFormElementSetValue($fwgt, $wgt) _IEFormElementSetValue($goods, $type) _IEFormElementRadioSelect($shipForm, "rHazmatNo", "rHazmat") _IEFormElementRadioSelect($shipForm, "rInbondNo", "rInbond") _IEFormElementSetValue($ref1, $eiref) _IEFormElementSetValue($instr, $special);;;;;;entering dims section _IELinkClickByText($oIE, "Enter Dims") _IELoadWait($oIE) $dimpieces = _IEFormElementGetObjByName($shipForm, "dimpieces") $dimlength = _IEFormElementGetObjByName($shipForm, "dimlength") $dimwidth = _IEFormElementGetObjByName($shipForm, "dimwidth") $dimheight = _IEFormElementGetObjByName($shipForm, "dimheight") $clickit = _IEGetObjByName($shipForm, "Clickit") Do $faplt = $aArray[$row][$floating_plt] $faL = $aArray[$row][$floating_L] $faW = $aArray[$row][$floating_W] $faH = $aArray[$row][$floating_H] Do Sleep(100) Until _IEFormElementGetValue($dimheight) = 0 If $faplt >= 1 Then _IEFormElementSetValue($dimpieces, $faplt) If $faplt >= 1 then _IEFormElementSetValue($dimlength, $faL) If $faplt >= 1 then _IEFormElementSetValue($dimwidth, $faW) If $faplt >= 1 then _IEFormElementSetValue($dimheight, $faH) If $faplt >= 1 then _IEAction($clickit, "click") $floating_plt = $floating_plt + 4 $floating_L = $floating_L + 4 $floating_W = $floating_W + 4 $floating_H = $floating_H + 4 Until $faplt < 1 ;;;;dims entering stops If not ProcessExists("popup.exe") Then Run("popup.exe", "") _IEAction($continue, "click") Sleep(6000) ;ConsoleWrite("After click") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;On Shipment info Screen ;I'm having to do the below loop to make sure i'm getting a certain value off of the table I want to make sure I'm on the right page. This is because the form is the same name still as onlineShipping Do Global $oIE = _IEAttach("Forward") _IEDocGetObj($oIE) Global $onlineshipping = _IEFormGetObjByName($oIE, "onlineShipping") Global $fwdntable = _IETableGetCollection($oIE, 8) Global $fwdnarray = _IETableWriteToArray($fwdntable, True) ;If IsArray($fwdnarray) then _ArrayDisplay($fwdnarray) If IsArray($fwdnarray) and UBound($fwdnarray, 1) > 4 and UBound($fwdnarray, 2) > 1 then $fwtender = StringStripWS($fwdnarray[4][1], 3) If IsArray($fwdnarray) and UBound($fwdnarray, 1) > 4 and UBound($fwdnarray, 2) > 1 then $fweta = StringStripWS($fwdnarray[5][1], 3) _ArrayDisplay($fwdnarray) ConsoleWrite(@lf & "waiting on eta to match") Sleep(2000) Until $fwtender = $date ConsoleWrite("out of loop") $onlineshipping = _IEFormGetObjByName($oIE, "onlineShipping") $fwdntable = _IETableGetCollection($oIE, 8) $fwdnarray = _IETableWriteToArray($fwdntable, True) $fwtender = StringStripWS($fwdnarray[4][1], 3) $fweta = StringStripWS($fwdnarray[5][1], 3) _Excel_RangeWrite($oExcel, "Input", $fwtender, "J" & $row+1) _Excel_RangeWrite($oExcel, "Input", $fweta, "K" & $row+1) $next = _IEGetObjByName($oIE, "B1") _IEAction($next, "click") _IELoadWait($oIE) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;On Contact info Screen ;Sleep(10000) ;ConsoleWrite("starting to Look after 10 seconds") MsgBox("", "stop check", "Click when on Contact Info screen") Do Global $oIE = _IEAttach("Forward") Global $consigneeform = _IEFormGetObjByName($oIE, "shipperConsigneeInfo") ConsoleWrite(@lf &"waiting on shipper contact screen") Sleep(2000) Until IsObj($consigneeform) $oIE = _IEAttach("Forward") $consigneeform = _IEFormGetObjByName($oIE, "shipperConsigneeInfo") $sphone = _IEFormElementGetObjByName($consigneeform, "sphone") $scontact = _IEFormElementGetObjByName($consigneeform, "scontact") $semail = _IEFormElementGetObjByName($consigneeform, "semail") $scemail = _IEFormElementGetObjByName($consigneeform, "scemail") $cname = _IEFormElementGetObjByName($consigneeform, "cname") $caddress1 = _IEFormElementGetObjByName($consigneeform, "caddress1") $caddress2 = _IEFormElementGetObjByName($consigneeform, "caddress2") $ccity = _IEFormElementGetObjByName($consigneeform, "ccity") $cprovincestate = _IEFormElementGetObjByName($consigneeform, "cprovincestate") $czip = _IEFormElementGetObjByName($consigneeform, "czip") $ccountry = _IEFormElementGetObjByName($consigneeform, "ccountry") $cphone = _IEFormElementGetObjByName($consigneeform, "cphone") $ccontact = _IEFormElementGetObjByName($consigneeform, "ccontact") $emrgyContact = _IEFormElementGetObjByName($consigneeform, "emrgyContact") $emrgyPhone = _IEFormElementGetObjByName($consigneeform, "emrgyPhone") $emrgyEmail = _IEFormElementGetObjByName($consigneeform, "emrgyEmail") $con_go = _IEGetObjByName($consigneeform, "B1") ;;;setting consigneeformvalues _IEFormElementSetValue($sphone, $uphone) _IEFormElementSetValue($scontact, $user) _IEFormElementSetValue($semail, $uemail) _IEFormElementSetValue($scemail, $uemail) _IEFormElementSetValue($cname, "Expeditors International " & $dest) _IEFormElementSetValue($caddress1, "Notify on Arrival") _IEFormElementSetValue($ccity, $dest) _IEFormElementSetValue($czip, "99999") _IEFormElementSetValue($cphone, $uphone) _IEFormElementSetValue($ccontact, "Transcon") _IEFormElementSetValue($emrgyContact, $user) _IEFormElementSetValue($emrgyPhone, $uphone) _IEFormElementSetValue($emrgyEmail,"DCS-IN-"&$currentbranch&"@EXPEDITORS.COM") ;MsgBox("", "", "after") _IEAction($con_go, "click") _IELoadWait($oIE) ;;;;shipment summary form _WaitOnForm("onlineShipmentSummary") $shipsummaryform = _IEFormGetObjByName($oIE, "onlineShipmentSummary") _IEFormElementCheckBoxSelect($shipsummaryform, "yes", "agree", 1, "byValue") $finalgo = _IEGetObjByName($shipsummaryform, "B1") If not ProcessExists("popup.exe") Then Run("popup.exe", "") _IEAction($finalgo, "click") ;;;;shipment booked form Do Global $oIE = _IEAttach("Forward") MsgBox("", "", "shipment summary") Global $bookingform = _IEFormGetObjByName($oIE, "premierShipmentBooking") ConsoleWrite("waiting on Summary screen") Sleep(2000) Until IsObj($bookingform) Local $oTable = _IETableGetCollection($oIE) Local $iNumTables = @extended MsgBox($MB_SYSTEMMODAL, "Table Info", "There are " & $iNumTables & " tables on the page") $bookingform = _IEFormGetObjByName($oIE, "premierShipmentBooking") $finaltable = _IETableGetCollection($oIE, 8) $finalarray = _IETableWriteToArray($finaltable, True) $chargetable = _IETableGetCollection($oIE, 10) $chargearray = _IETableWriteToArray($chargetable, True) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;check array $chargerow = _ArraySearch($chargearray, "Total Charges:", 0, 0, 0, 1) $fastbook = $finalarray[6][1] $edocnumber = $finalarray[8][1] $fwdncharges = $chargearray[$chargerow][1] $print = _IEFormElementGetObjByName($bookingform, "pdfButton") _IEAction($print, "click") MsgBox("", "stop check", "stop") _Excel_RangeWrite($oExcel, "Input", $fastbook, "I" & $row+1) _Excel_RangeWrite($oExcel, "Input", $fwdncharges, "C" & $row+1) If ProcessExists("popup.exe") Then ProcessClose("popup.exe") WinActivate("http://forwardair.com/servlet/fwrd.unix.servlet.GetAirbillPDFServlet - Windows Internet Explorer") sleep(5000) ;;;go to airbill print Send("{CTRLDOWN}") Send("{p}") Send("{CTRLUP}") WinWaitActive("Print") Send("{ENTER}") WinWaitActive("Output Source") Send("{Enter}") WinClose("http://forwardair.com/servlet/fwrd.unix.servlet.GetAirbillPDFServlet - Windows Internet Explorer") WinWait("Print2edoc") $edoc = WinGetTitle("Print2edoc") $checkbillforedoc = StringLeft($edocnumber, 3) If $currentbranch = $checkbillforedoc Then ControlSend($edoc, "", "[CLASS:TComboBox; INSTANCE:2]", "CONSOL") If $currentbranch <> $checkbillforedoc Then ControlSend($edoc, "", "[CLASS:TComboBox; INSTANCE:2]", "HOUSE_BILL") ;ClipPut($eiref) ControlSetText($edoc, "", "[CLASS:TScaleMemo; INSTANCE:2]", $eiref) ControlSend($edoc, "", "[CLASS:TComboBox; INSTANCE:1]", "Truck Bill") ControlClick($edoc, "Send", "[CLASS:TButton; INSTANCE:2]", "left", "1") ControlClick($edoc, "", "[CLASS:TButton; INSTANCE:2]") ;WinWaitActive("http://forwardair.com/servlet/fwrd.unix.servlet.GetAirbillPDFServlet - Windows Internet Explorer") ;$ieclose = WinGetTitle("http://forwardair.com/servlet/fwrd.unix.servlet.GetAirbillPDFServlet - Windows Internet Explorer") $row = $row + 1 Until $row = $counter + 1 sleep(3000) MsgBox("","", "Script Completed"&@lf&""&@lf&"Check All Data Before Linking IC's") Case $GUI_EVENT_CLOSE ;;Close Gui Exit Case $opentool $oExcel = _ExcelBookOpen($filelocation & "bulkbook.xlsm") EndSwitch WEnd Edited May 27, 2015 by dar100111
dar100111 Posted May 28, 2015 Author Posted May 28, 2015 (edited) Hey Everyone. I've been working on a solution and I found something really strange and I did find something that seems to be working only I can't understand why a Sleep() would not be able to do the same instance, or just letting this loop go until it finds the Form I'm looking for. Anyone that can explain why this would be? Commenting out the MsgBox will keep it stuck in the loop. Using the MsgBox allows finding the Form. Sleep in the place of the MsgBox will never refresh the Form when it gets to the right place. Func _WaitOnForm2($_form_name) $killcount = 1 Do Local $zIE = _IEAttach("Forward") Local $zForm = _IEFormGetObjByName($zIE, $_form_name) ConsoleWrite(@lf & "waiting on " & $_form_name & " form to appear") MsgBox("", "", "Waiting on " & $_form_name, 1) $killcount += 1 If $killcount > 15 Then MsgBox("", "", "Kill Error") Exit EndIf Until IsObj($zForm) EndFunc Edited May 28, 2015 by dar100111
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now