crzymnmchl

get _IECreateEmbedded to work with html page loading js library

1 post in this topic

I cannot get any of my localhost pages that use Angular, jQuery, ExtJS etc to load into the embedded. All work perfectly with _IECreate of course. I started with

$oNav = _IENavigate($oIE, @ScriptDir & '/angularjs-hello-world.html', 0)

but that gave me nothing but _IE error messages with long integers - so went simpler(?) to my local server with

$oNav = _IENavigate($oIE, 'http://localhost:8080/Angular/angularjs-hello-world.html')

which opens the embedded page

<!-- saved from url=(0016)http://127.0.0.1 -->
<!DOCTYPE html>
<html>

<head>
    <script src="js/libs/angular.min.js"></script>
</head>

<body ng-app>
  <input type="text"
         ng-model="name"
         placeholder="Enter your name">
  <h1>Hello <span ng-bind="name"></span></h1>

</body>

</html>

but with no Angular ... the html objects are there e.g the input field but the Angular "Enter your name" is not there .... I do not think the js library is loading.

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

Local $oIE = _IECreateEmbedded()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 10, 40, 600, 360)

Global $g_idError_Message = GUICtrlCreateLabel("", 100, 500, 500, 30)
GUICtrlSetColor(-1, 0xff0000)

GUISetState(@SW_SHOW) ;Show GUI

_IENavigate($oIE, 'http://localhost:8080/Angular/angularjs-hello-world.html')
CheckError("Init", @error, @extended)

; Waiting for user to close the window
While 1
    Local $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop        
    EndSelect
WEnd

GUIDelete()

Exit

Func CheckError($sMsg, $iError, $iExtended)
    If $iError Then
        $sMsg = "Error using " & $sMsg & " button (" & $iExtended & ")"
    Else
        $sMsg = ""
    EndIf
    GUICtrlSetData($g_idError_Message, $sMsg)
EndFunc   ;==>CheckError

Works perfectly when run from localhost: and also when the html file is run from file system. The example for _IECreateEmbedded (which I shortened above) goes to www.autoit which loads jQuery so I know doable. First comment in html is meant to tweek IE security and I have been giving IE as much activeX settings as possible as I wonder if this is Win7/IE11 security?

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

  • Similar Content

    • rootx
      By rootx
      1. The script in ie works without errors, why in Autoit does not work?
      2. My goal: I would like to read the contents of the "
      map.panTo(posizione); " variable from the map and save it to a variable in autoit to use it.
      THX.
      PS: you need gmaps API key to execute it locally.
       
      #include-once #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <IE.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 801, 601, 192, 124) GUISetState(@SW_SHOW) map() #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func map() $apikey = "Insert your api key" $html = _ "<!DOCTYPE html>" & @CRLF & _ "<html>" & @CRLF & _ " <head>" & @CRLF & _ " <meta charset=""utf-8"">" & @CRLF & _ " <title>Searchbox</title>" & @CRLF & _ " <style>" & @CRLF & _ " #map {" & @CRLF & _ " height: 100%;" & @CRLF & _ " }" & @CRLF & _ " html, body {" & @CRLF & _ " height: 100%;" & @CRLF & _ " margin: 0;" & @CRLF & _ " padding: 0;" & @CRLF & _ " }" & @CRLF & _ " #map { " & @CRLF & _ " height: 99%; " & @CRLF & _ " width: 99%;" & @CRLF & _ " } " & @CRLF & _ " #pac-input{" & @CRLF & _ " margin: 10 10 10 10;" & @CRLF & _ " width: 200px;" & @CRLF & _ " position: absolute; top: 10px; left: 400px; z-index: 99;" & @CRLF & _ " }" & @CRLF & _ " </style>" & @CRLF & _ " </head>" & @CRLF & _ " <body>" & @CRLF & _ " <div id=""map""></div>" & @CRLF & _ " <script>" & @CRLF & _ "" & @CRLF & _ " function initAutocomplete() {" & @CRLF & _ " var myLatLng = {lat: 41.8956142, lng: 12.5029109}; " & @CRLF & _ " var map = new google.maps.Map(document.getElementById('map'), {" & @CRLF & _ " center: myLatLng," & @CRLF & _ " zoom:15," & @CRLF & _ " mapTypeId: 'roadmap'" & @CRLF & _ " });" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " var markers = [];" & @CRLF & _ " " & @CRLF & _ " map.addListener('click', function(e) {" & @CRLF & _ " placeMarker(e.latLng, map); " & @CRLF & _ " " & @CRLF & _ " });" & @CRLF & _ " " & @CRLF & _ " function placeMarker(position, map) {" & @CRLF & _ " " & @CRLF & _ " var marker = new google.maps.Marker({" & @CRLF & _ " position: position," & @CRLF & _ " map: map " & @CRLF & _ " }); " & @CRLF & _ " var lastpos = position;" & @CRLF & _ " markers.push(marker);" & @CRLF & _ " for (var i = 0; i < markers.length; i++) {" & @CRLF & _ " if (markers[i].getPosition() != lastpos) { " & @CRLF & _ " markers[i].setMap(null);" & @CRLF & _ " markers.splice(i, 1)" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " mapMove(lastpos);" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " function mapMove(posizione){" & @CRLF & _ " map.panTo(posizione);" & @CRLF & _ " alert(posizione);" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " </script>" & @CRLF & _ " <script src=""https://maps.googleapis.com/maps/api/js?key="&$apikey&"&libraries=places&callback=initAutocomplete""" & @CRLF & _ " async defer></script>" & @CRLF & _ " </body>" & @CRLF & _ "</html>" $gmap = _IECreateEmbedded() $gmap_ctrl = GUICtrlCreateObj($gmap, 5, 5, 750, 550) _IENavigate($gmap, "about:blank", 0) _IEDocWriteHTML($gmap, $html) EndFunc <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Searchbox</title> <style> #map { height: 100%; } html, body { height: 100%; margin: 0; padding: 0; } #map { height: 99%; width: 99%; } #pac-input{ margin: 10 10 10 10; width: 200px; position: absolute; top: 10px; left: 400px; z-index: 99; } </style> </head> <body> <div id="map"></div> <script> function initAutocomplete() { var myLatLng = {lat: 41.8956142, lng: 12.5029109}; var map = new google.maps.Map(document.getElementById('map'), { center: myLatLng, zoom:15, mapTypeId: 'roadmap' }); var markers = []; map.addListener('click', function(e) { placeMarker(e.latLng, map); }); function placeMarker(position, map) { var marker = new google.maps.Marker({ position: position, map: map }); var lastpos = position; markers.push(marker); for (var i = 0; i < markers.length; i++) { if (markers[i].getPosition() != lastpos) { markers[i].setMap(null); markers.splice(i, 1) } } mapMove(lastpos); } function mapMove(posizione){ map.panTo(posizione); alert(posizione); } } </script> <script src="https://maps.googleapis.com/maps/api/js?key=yourapikey&libraries=places&callback=initAutocomplete" async defer></script> </body> </html>  
    • Patryk
      By Patryk
      Dear Colleagues,
      I have no idea how to refer to style.display in my loop. There is a button like: 
      <input name="ctl00$bodyPlaceholder$btnFecharProcessamento" class="button" id="bodyPlaceholder_btnFecharProcessamento" style="display: none;" onclick="FecharJanelaProcessamento();return false;" type="submit" value="Fechar"> I want it to be clicked as soon as button's style change from style="display: none;" to  style= ="display: inline-block;" 
      This is what I got, but it's not working...
      Func GetButtons() $oButtons = _IEGetObjByName($oForm,"ctl00$bodyPlaceholder$btnFecharProcessamento",-1) $i = 0 While $i <> 1 For $oBtn In $oButtons If _IEFormElementGetValue($oBtn) = "Fechar" And $oBtn.document.style.display = "display: inline-block;" Then $i = 1 _IEAction($oBtn, "focus") _IEAction($oBtn, "click") ExitLoop EndIf Next WEnd EndFunc  
      I will really appreciate if you could help me with these loop!
    • Omnitica
      By Omnitica
      Hello!
      I'm new to the forums! Couldn't find any threads covering this issue. Sorry if I'm wrong.

      I'm having problems changing the text/value of a input box. The particular box doesn't have a name or id, just: class="jq_hotkeys_enabled form-control".
      This class appears multiple times throughout the source, so I don't think It's right to reference that object. 
      See image 1.
      However, I've managed to find a object with the name "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper" which contains the value of the input box, and the id for the person in the dropdown/combobox left of it. (with "dummy-1" selected).
      See image 2.
      As you can see the value is 3982,4545     ( name , time )
      But when I try to change the value of it by doing:
      #include <IE.au3> Local $oIE = _IEAttach(WinGetHandle("[CLASS:IEFrame]"),"embedded") Local $oForm = _IEFormGetObjByName($oIE, "aspnetForm") Local $oInput = _IEFormElementGetObjByName($oForm, "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper") _IEFormElementSetValue($oInput, "3982,1337") The box doesn't get its new value. I  can see in the source that it's changed though.
      See image 3.
       
      However, if I do: 
      #include <IE.au3> Local $oIE = _IEAttach(WinGetHandle("[CLASS:IEFrame]"),"embedded") Local $oForm = _IEFormGetObjByName($oIE, "aspnetForm") Local $oInput = _IEFormElementGetObjByName($oForm, "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper") _IEFormElementSetValue($oInput, "3982,1337") $oIE.document.parentwindow.execScript("theForm.submit()") ; But it needs to reload the page The box gets its new value after the page reloads by the theForm.submit() function. 
      This is a bit unfortunate as I want the changes to happen instantly like when I type in the box with the keyboard... or select in the combobox.
      Maybe someone knows how I can do this? Looking forward to an answer! 
      Thanks in advance.
       
      Note: Unfortunately I can't provide with the real URL as it is constricted to employees in the company I work for, but let me know If I should provide anything else.
       



    • milos83
      By milos83
      How can I check if element is focused in Firefox using FF.au3 UDF?
      This is my try:
      I have prepared a function that checks if the object is focused:
       
      _FFCmd('FFau3.isfocused=function isfocused(a){try{return (a === document.activeElement)}catch(e){return}}') $oElm = _FFXPath("//*[@id='someId']") ConsoleWrite(_FFIsFocused($oElm)) Func _FFIsFocused($sElement = "") Local $isFoc = _FFCmd("FFau3.isfocused(" & $sElement & ")") Return $isFoc EndFunc ;==>_FFIsFocused Now, the javascript part is tested and it does return successfully.
      After a lot of try/fails I inserted an alert box in order to display the object being compared.
      Here is what I got
       
      The focused object is: [object XULElement]
      The object that I send for comparing is [object HTMLInputElement]
      Why is that?
       
       
    • Chimp
      By Chimp
      Hi all.
      I'm playing a bit with the ScriptControl object using as base this example by @genius257.
      here is a very simple try, ... but it fails. what I'm doing wrong?
      Local $oSC = ObjCreate("ScriptControl") $oSC.Language = "JScript" $oSC.ExecuteStatement('alert("I am a javascript alert box!");') MsgBox(0,'AutoIt','Pause') Thanks