KenNichols Posted April 22, 2009 Share Posted April 22, 2009 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) $fadd = GUICtrlRead($txtfromAdd) $fcity = GUICtrlRead($txtfromcity) $fstate = GUICtrlRead($txtfromstate) $tadd = GUICtrlRead($txttoAdd) $tcity = GUICtrlRead($txttocity) $tstate = GUICtrlRead($txttostate) $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")) $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) $fadd = GUICtrlRead($txtfromAdd) $fcity = GUICtrlRead($txtfromcity) $fstate = GUICtrlRead($txtfromstate) $tadd = GUICtrlRead($txttoAdd) $tcity = GUICtrlRead($txttocity) $tstate = GUICtrlRead($txttostate) $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,1) _IELoadWait($oIE) GUISetCursor(2) EndFunc [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...
Qousio Posted April 22, 2009 Share Posted April 22, 2009 Would be better if you learned theory of graphs and made a programm that actually calculates mileage Link to comment Share on other sites More sharing options...
DaleHohm Posted April 22, 2009 Share Posted April 22, 2009 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=671222Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds 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 Link to comment Share on other sites More sharing options...
KenNichols Posted April 22, 2009 Author Share Posted April 22, 2009 The script works fine, I was hoping to get some constructive criticism. Anyone? [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...
Valuater Posted April 22, 2009 Share Posted April 22, 2009 Just some ideas... Embed it List directions get weather altitude printable ??? 8) Link to comment Share on other sites More sharing options...
NBJ Posted April 23, 2009 Share Posted April 23, 2009 @KenNichols Well done First thing to would be to check if the website is replying in Miles or KM. Add some fields for Country. Cheers NBJ Link to comment Share on other sites More sharing options...
EdWilson Posted May 3, 2013 Share Posted May 3, 2013 As identified in this topic...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. 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