Sign in to follow this  
Followers 0
KenNichols

IE Help Needed

3 posts in this topic

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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
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
Sign in to follow this  
Followers 0