KenNichols Posted May 12, 2009 Share Posted May 12, 2009 Even with the same addresses 9 out of 10 times this function works perfect! Not sure why it doesn't always work though. CODEFunc MileageandTravelTime($fadd, $fcity, $fstate, $tAdd, $tcity, $tstate) $Start = ($fadd & ", " & $fcity & " " & $fstate) $End = ($tAdd & ", " & $tcity & " " & $tstate) $sUrl = "http://maps.google.com/maps?f=d&hl=en&saddr=" & StringReplace($Start & "&daddr=" & $End, " ", "+") $oIE = _IECreate($sUrl, 0, 0) _IELoadWait($oIE) $oDiv = _IEGetObjById($oIE, "dditd") $Result = (_IEPropertyGet($oDiv, "innertext")) If $Result = "" Then _IEQuit($oIE) EndIf $data = StringSplit($Result, "") If @error = 1 Then _ArrayInsert($data, 1, "Error: Mi ") _ArrayInsert($data, 2, " Error: Distance ") EndIf $data1 = StringTrimRight($data[1], 1) $data1 = $data1 & "les" $data2 = StringTrimLeft($data[2], 7) $data2 = StringTrimRight($data2, 1) If StringRight($data2, 3) = "min" Then $data2 = $data2 & "utes" ElseIf StringRight($data2, 3) = "our" Then $data2 = $data2 & "s" Else $data2 = $data2 EndIf $MileageandTi = ($data1 & @CRLF & $data2) _IEQuit($oIE) Return $MileageandTi EndFunc ;==>MileageandTravelTime [topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner! Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 12, 2009 Share Posted May 12, 2009 Even with the same addresses 9 out of 10 times this function works perfect! Not sure why it doesn't always work though.You need to say exactly what happens when it doesn't work. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
KenNichols Posted May 12, 2009 Author Share Posted May 12, 2009 You need to say exactly what happens when it doesn't work. While writing this reply and trying to explain exactly what was/wasn't happening. I figured out why I was getting the error.Thanks! [topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner! Link to comment Share on other sites More sharing options...
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