Jump to content

IE Help Needed


Recommended Posts

Even with the same addresses 9 out of 10 times this function works perfect!

Not sure why it doesn't always work though.

CODE
Func 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...