This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X

# Useing Google Maps to calculate mileage from Point A to Point B

6 replies to this topic

### #1 KenNichols

KenNichols

• Active Members
• 121 posts

Posted 22 April 2009 - 06:39 PM

I am new! Pick it apart and help me make it Better!

#include <IE.au3>
#include <GUIConstants.au3>

#Region ### START Koda GUI section ###
\$Form1= GUICreate("How many Miles?", 377, 248, 194, 116)
GUISetCursor (2)
\$txtfromAdd = GUICtrlCreateInput("", 8, 48, 153, 21)
\$Label1 = GUICtrlCreateLabel("From:", 8, 8, 45, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
\$Label2 = GUICtrlCreateLabel("Street Address", 8, 32, 73, 17)
\$txtfromcity = GUICtrlCreateInput("", 8, 96, 153, 21)
\$Label3 = GUICtrlCreateLabel("City", 8, 80, 21, 17)
\$txtfromstate = GUICtrlCreateInput("", 8, 144, 153, 21)
\$Label4 = GUICtrlCreateLabel("State", 8, 128, 29, 17)
\$txttoAdd = GUICtrlCreateInput("", 216, 48, 153, 21)
\$Label5 = GUICtrlCreateLabel("To:", 216, 8, 26, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
\$Label6 = GUICtrlCreateLabel("Street Address", 216, 32, 73, 17)
\$txttocity = GUICtrlCreateInput("", 216, 96, 153, 21)
\$Label7 = GUICtrlCreateLabel("City", 216, 80, 21, 17)
\$txttostate = GUICtrlCreateInput("", 216, 144, 153, 21)
\$Label8 = GUICtrlCreateLabel("State", 216, 128, 29, 17)
\$BtnCalc = GUICtrlCreateButton("Calculate", 240, 192, 105, 25)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
\$lblMilage = GUICtrlCreateLabel("", 88, 192, 103, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
\$Label9 = GUICtrlCreateLabel("Distance =", 8, 195, 80, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
\$VMap = GUICtrlCreateButton("View Map", 256, 224, 73, 17, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE
Exit
EndSwitch
If \$nMsg = \$BtnCalc Then Mileage()
If \$nMsg = \$VMap Then Map()

WEnd

Func Mileage()
GUICtrlSetData(\$lblMilage,"")
GUISetCursor(15)

\$Start = (\$fadd & ", " & \$fcity & " " & \$fstate)
\$End = (\$tadd & ", " & \$tcity & " " & \$tstate)

\$oIE = _IECreate(\$sUrl,0,0)

\$oDiv = _IEGetObjById(\$oIE, "dditd")
\$Result = (_IEPropertyGet(\$oDiv, "innertext"))

\$data = StringRegExp(\$Result, "([0-9]+.[0-9]+)",1)

If \$data = "" Then
MsgBox(0, "Mileage Calculation Error", "Mileage Calculation Error")
Map()
Else
GUICtrlSetData(\$lblMilage,\$data[0] & " Miles")
_IEQuit (\$oIE)
GUISetCursor(2)
EndIf
EndFunc

Func Map()
GUISetCursor(15)

\$Start = (\$fadd & ", " & \$fcity & " " & \$fstate)
\$End = (\$tadd & ", " & \$tcity & " " & \$tstate)

\$oIE = _IECreate(\$sUrl,0,1)

GUISetCursor(2)

EndFunc

### #2 Qousio

Qousio

Prodigy

• Active Members
• 169 posts

Posted 22 April 2009 - 06:55 PM

Would be better if you learned theory of graphs and made a programm that actually calculates mileage

### #3 DaleHohm

DaleHohm

Think of IE as an API...

• MVPs
• 5,986 posts

Posted 22 April 2009 - 08:00 PM

Would be better if you learned theory of graphs and made a programm that actually calculates mileage

Nah, really, get yourself a pedometer and walk off the distance.

Recently discussed... see here: http://www.autoitscript.com/forum/index.ph...st&p=671222

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

Automate input type=file (Related)

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y
Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

### #4 KenNichols

KenNichols

• Active Members
• 121 posts

Posted 22 April 2009 - 09:22 PM

The script works fine, I was hoping to get some constructive criticism. Anyone?

### #5 Valuater

Valuater

www.PayFreeWireless.com

• MVPs
• 11,214 posts

Posted 22 April 2009 - 09:42 PM

Just some ideas...

Embed it
List directions
get weather
altitude
printable

???

8)

Clic The Pic!!!

### #6 NBJ

NBJ

Seeker

• Active Members
• 48 posts

Posted 23 April 2009 - 02:02 AM

@KenNichols
Well done
First thing to would be to check if the website is replying in Miles or KM.

Cheers
NBJ

### #7 EdWilson

EdWilson

Seeker

• Active Members
• 14 posts

Posted 03 May 2013 - 03:21 AM

As identified in this topic...http://www.autoitscript.com/forum/topic/93425-ie-help/page__gopid__1074617#entry1074617

Because Google appears to have updated the way they code their html, simply change "dditd" to "altroute_0" in the above code. Can get altroute_1 or altroute_2 as well if those are presented.

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users