GreenCan Posted July 11, 2011 Share Posted July 11, 2011 Does anyone know why this doesn't function as embedded url using _IECreateEmbedded? While the same code works with _IECreate Thanks expandcollapse popup#include <Google Maps.au3> #include <IE.au3> #Include <File.au3> #Include <GuiListBox.au3> #===================== ; for test purpose - generate unique html filename in @TempDir Global $s_TempFile = _TempFile(@ScriptDir, "temp_", ".html") Global $oIE #===================== Global $main_gui Global $window_width = 900 Global $window_heigth = 800 ; Setup Main GUI $main_gui = GUICreate("Google Directions Example", $window_width, $window_heigth, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX)) ; direction parameters $start_route_input = "40.910432,-73.892241" $end_route_input = "40.910432,-73.892241" $Waypoint_1 = "Bronx, NY, USA," $Waypoint_2 = "New Rochelle, NY, USA," $Waypoint_3 = "Mt Vernon, NY, USA," $Waypoint_4 = "" $Waypoint_5 = "" $Waypoint_6 = "" $Waypoint_7 = "" $Waypoint_8 = "" $travel_mode_list = GUICtrlCreateList("", $window_width - 110, $window_heigth - 115, 100, 50, BitOR($WS_BORDER, $WS_VSCROLL)) GUICtrlSetData(-1, "Driving|Walking|Bicyling", "Driving") $travel_mode = 0 GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT + $GUI_DOCKBOTTOM ) $close_button = GUICtrlCreateButton("Close (Esc)", $window_width -90, $window_heigth - 50, 80, 20) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE ) ; Show Main GUI GUISetState(@SW_SHOW) $Return = _GUICtrlGoogleMap_Directions(0, 0, $window_width, $window_heigth - 155, ($start_route_input), ($end_route_input), _GUICtrlListBox_GetCurSel($travel_mode_list), ($Waypoint_1), ($Waypoint_2), ($Waypoint_3), ($Waypoint_4), ($Waypoint_5), ($Waypoint_6)) while 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE or $msg = $close_button #===================== ConsoleWrite($s_TempFile & @CR) _IEQuit ( $oIE ) ; doesn't functyion in Windows 7 - IE9 If WinExists ($s_TempFile & " - Windows Internet Explorer" ) Then WinClose($s_TempFile) ; doesn't function neither in Windows 7 - IE9 FileDelete($s_TempFile) #===================== GUIDelete() ExitLoop Case $msg = $travel_mode_list ; case travel mode changed, dynamically calculate route If _GUICtrlListBox_GetCurSel($travel_mode_list) <> $travel_mode Then $travel_mode = _GUICtrlListBox_GetCurSel($travel_mode_list) $Return = _GUICtrlGoogleMap_Directions(0, 0, $window_width, $window_heigth - 155, ($start_route_input), ($end_route_input), _GUICtrlListBox_GetCurSel($travel_mode_list), ($Waypoint_1), ($Waypoint_2), ($Waypoint_3), ($Waypoint_4), ($Waypoint_5), ($Waypoint_6)) EndIf EndSelect WEnd Exit ; #FUNCTION# ;=============================================================================== ; ; Name...........: _GUICtrlGoogleMap_Directions() ; Description ...: Gets directions for a route. ; Syntax.........: _GUICtrlGoogleMap_Directions($left, $top, $width, $height, $start_route_input, $travel_mode = 0 [, $end_route_input, [ $Waypoint_1 = "" [, $Waypoint_2 = "" [, $Waypoint_3 = "" [, $Waypoint_4 = "" [, $Waypoint_5 = "" [, $Waypoint_6 = "" [, $Waypoint_7 = "" [, $Waypoint_8 = "" ]]]]]]]]) ; Parameters ....: $left - The left side of the control. ; $top - The top of the control. ; $width - The width of the control. ; $height - The height of the control. ; $start_route_input - An address (either a location or latitude and longitude) from which the route will start ; ie. both "Sydney, New South Wales, Australia" and "-34.397, 150.644" are valid. ; $end_route_input - An address where the route will end ; $travel_mode - 0 = (Default) Uses a travel mode of DRIVING ; 1 = Uses a travel mode of WALKING ; 2 = Uses a travel mode of BICYCLING ; $Waypoint_1 - [optional] Waypoint 1, an address where the route will pass along ; $Waypoint_2 - [optional] Waypoint 2, an address where the route will pass along ; $Waypoint_3 - [optional] Waypoint 3, an address where the route will pass along ; $Waypoint_4 - [optional] Waypoint 4, an address where the route will pass along ; $Waypoint_5 - [optional] Waypoint 5, an address where the route will pass along ; $Waypoint_6 - [optional] Waypoint 6, an address where the route will pass along ; $Waypoint_7 - [optional] Waypoint 7, an address where the route will pass along ; $Waypoint_8 - [optional] Waypoint 8, an address where the route will pass along ; Return values .: On Success - Returns the identifier (controlID) of the new control. ; On Failure - Returns False. ; Author ........: Greencan ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; ; ;========================================================================================== Func _GUICtrlGoogleMap_Directions($left, $top, $width, $height, $start_route_input, $end_route_input, $travel_mode = 0, $Waypoint_1 = "", $Waypoint_2 = "", $Waypoint_3 = "", $Waypoint_4 = "", $Waypoint_5 = "", $Waypoint_6 = "", $Waypoint_7 = "", $Waypoint_8 = "") ; check if Internet available If Ping ( "maps.google.com" ) = 0 Then Return False If $start_route_input = "" Then MsgBox(48,"Error","Missing origin address") Return False EndIf If $end_route_input = "" Then MsgBox(48,"Error","Missing destination address") Return False EndIf ; set waypoints in array and remove empty elements $Waypoints = StringSplit($Waypoint_1 & "|" & $Waypoint_2 & "|" & $Waypoint_3 & "|" & $Waypoint_4 & "|" & $Waypoint_5 & "|" & $Waypoint_6 & "|" & $Waypoint_7 & "|" & $Waypoint_8, "|" ) ; remove empty waypoints For $i = $Waypoints[0] to 1 step -1 If $Waypoints[$i] = "" Then _ArrayDelete($Waypoints, $i) EndIf Next ; correct number of elements $Waypoints[0] = UBound($Waypoints) - 1 ; build waypoints $_Waypoints = " waypoints:[" For $i = 1 To $Waypoints[0] ConsoleWrite($Waypoints[$i] & @CR) $_Waypoints &= "{location: '" & $Waypoints[$i] & "'}," Next If $_Waypoints = " waypoints:[" Then $_Waypoints = "" Else $_Waypoints = StringTrimRight($_Waypoints,1) & "]," & @CRLF EndIf ; set travel mode If $travel_mode = 0 Then $_travelMode = " travelMode: google.maps.DirectionsTravelMode.DRIVING" & @CRLF ElseIf $travel_mode = 1 Then $_travelMode = " travelMode: google.maps.DirectionsTravelMode.WALKING" & @CRLF Else $_travelMode = " travelMode: google.maps.DirectionsTravelMode.BICYCLING" & @CRLF ; only in USA EndIf Local Const $html = _ "<!DOCTYPE HTML>" & @CRLF & _ "<HTML><HEAD>" & @CRLF & _ "<link href='http://code.google.com/apis/maps/documentation/javascript/examples/default.css' rel='stylesheet' type='text/css' />" & @CRLF & _ "<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'></script>" & @CRLF & _ "<script type='text/javascript'>" & @CRLF & _ " var rendererOptions = {" & @CRLF & _ " draggable: true" & @CRLF & _ " };" & @CRLF & _ " var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);" & @CRLF & _ " var directionsService = new google.maps.DirectionsService();" & @CRLF & _ " var map;" & @CRLF & _ " // var belgium = new google.maps.LatLng(-25.274398, 133.775136);" & @CRLF & _ " function initialize() {" & @CRLF & _ " var myOptions = {" & @CRLF & _ " zoom: 7," & @CRLF & _ " mapTypeId: google.maps.MapTypeId.ROADMAP," & @CRLF & _ " };" & @CRLF & _ " map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);" & @CRLF & _ " directionsDisplay.setMap(map);" & @CRLF & _ " directionsDisplay.setPanel(document.getElementById('directionsPanel'));" & @CRLF & _ " google.maps.event.addListener(directionsDisplay, 'directions_changed', function() {" & @CRLF & _ " computeTotalDistance(directionsDisplay.directions);" & @CRLF & _ " });" & @CRLF & _ " calcRoute();" & @CRLF & _ " }" & @CRLF & _ " function calcRoute() {" & @CRLF & _ " var request = {" & @CRLF & _ " origin: '" & $start_route_input & "'," & @CRLF & _ " destination: '" & $end_route_input &"'," & @CRLF & _ $_Waypoints & $_travelMode & _ " };" & @CRLF & _ " directionsService.route(request, function(response, status) {" & @CRLF & _ " if (status == google.maps.DirectionsStatus.OK) {" & @CRLF & _ " directionsDisplay.setDirections(response);" & @CRLF & _ " }" & @CRLF & _ " });" & @CRLF & _ " }" & @CRLF & _ " function computeTotalDistance(result) {" & @CRLF & _ " var total = 0;" & @CRLF & _ " var myroute = result.routes[0];" & @CRLF & _ " for (i = 0; i < myroute.legs.length; i++) {" & @CRLF & _ " total += myroute.legs[i].distance.value;" & @CRLF & _ " }" & @CRLF & _ " total = total / 1000." & @CRLF & _ " document.getElementById('total').innerHTML = total + ' km';" & @CRLF & _ " }" & @CRLF & _ "</SCRIPT>" & @CRLF & _ "<BODY onload=initialize()>" & @CRLF & _ "<DIV style='WIDTH: 70%; FLOAT: left; HEIGHT: 100%' id=map_canvas></DIV>" & @CRLF & _ "<DIV style='WIDTH: 30%; FLOAT: right' id=directionsPanel>" & @CRLF & _ "<P>Total Distance: <SPAN id=total></SPAN></P></DIV></BODY></HTML>" & @CRLF ; ConsoleWrite($html) #===================== ; put the new content in a text file for testing $file = FileOpen ($s_TempFile, 2 ) If $file = -1 Then MsgBox(0, "Error", "Unable to open file temp.html") Else FileWrite($file, $html) FileClose($file) EndIf If Not WinExists ($s_TempFile & " - Windows Internet Explorer" ) Then; & "\temp.html - Windows Internet Explorer" ) Then $oIE = _IECreate($s_TempFile,1,1,0) Else ;_IEAction ($oIE,"refresh") WinActivate($s_TempFile & " - Windows Internet Explorer") ; & " - Windows Internet Explorer") Send("{F5}") EndIf #===================== $gmapDir = _IECreateEmbedded () $gmapDir_ctrl = GUICtrlCreateObj($gmapDir, $left, $top, $width, $height) _IENavigate($gmapDir, "about:blank") _IEDocWriteHTML($gmapDir, $html) $gmapDir.refresh() Return $gmapDir EndFunc ;==>_GUICtrlGoogleMap_Directions Contributions CheckUpdate - SelfUpdating script ------- Self updating script Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple MsgBox with CountDown ------------------- MsgBox with visual countdown Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV) USB Drive Tools ------------------------------ Tool to help you with your USB drive management Input Period udf ------------------------------ GUI for a period input Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette Excel Chart UDF ----------------------------- Collaboration project with water GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm TaskListAllDetailed --------------------------- List All Scheduled Tasks Computer Info --------------------------------- A collection of information for helpdesk Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only) Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane Oracle SQL Report Generator ------------- Oracle Report generator using SQL SQLite Report Generator ------------------- SQLite Report generator using SQL SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access Animated animals ----------------------------- Fun: Moving animated objects Perforated image in GUI --------------------- Fun: Perforate your image with image objects UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool Visual Image effect (GUI) -------------------- Visually apply effects on an image Link to comment Share on other sites More sharing options...
GreenCan Posted July 12, 2011 Author Share Posted July 12, 2011 any suggestions? The example opens Internet explorer (line 209-223) and shows Google directions (after allowing blocked contents due to ActiveX) But the following lines (226-230) result in a blank screen in the embedded Windows (except for the html part (Total Distance) Highlighting the Travelmode will change the route in IE but again the embedded remains blank Contributions CheckUpdate - SelfUpdating script ------- Self updating script Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple MsgBox with CountDown ------------------- MsgBox with visual countdown Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV) USB Drive Tools ------------------------------ Tool to help you with your USB drive management Input Period udf ------------------------------ GUI for a period input Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette Excel Chart UDF ----------------------------- Collaboration project with water GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm TaskListAllDetailed --------------------------- List All Scheduled Tasks Computer Info --------------------------------- A collection of information for helpdesk Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only) Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane Oracle SQL Report Generator ------------- Oracle Report generator using SQL SQLite Report Generator ------------------- SQLite Report generator using SQL SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access Animated animals ----------------------------- Fun: Moving animated objects Perforated image in GUI --------------------- Fun: Perforate your image with image objects UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool Visual Image effect (GUI) -------------------- Visually apply effects on an image 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