Search the Community
Showing results for tags 'feature_browser_emulation'.
-
IE is not new but newer versions are not emulated ( IE8+ ) so a function to expressly set the IE version to load when embedded was needed. Otherwise some technologies will not behave as expected of a modern browser. #include <GUIConstantsEx.au3> #include <IE.au3> #include <WindowsConstants.au3> Func _IEGetEmbeddedBrowserEmulation() Local $iRet = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", _ StringTrimLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1))) Return SetError(@error, @extended, $iRet) EndFunc ;==>_IEGetEmbeddedBrowserEmulation Func _IESetEmbeddedBrowserEmulation($FEATURE_BROWSER_EMULATION = Default) ; ..update as of 6/28/2020 If Not Int($FEATURE_BROWSER_EMULATION) And Not IsKeyword($FEATURE_BROWSER_EMULATION) Then RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", _ StringTrimLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1))) Return SetError(@error, 2, "") EndIf Local $iRet = _IEGetEmbeddedBrowserEmulation() If $FEATURE_BROWSER_EMULATION = Default Then $FEATURE_BROWSER_EMULATION = Int(FileGetVersion("ieframe.dll")) * 1000 If Int($FEATURE_BROWSER_EMULATION) = 0 Then Return SetError(10, 3, $iRet) If $iRet <> $FEATURE_BROWSER_EMULATION Then ; https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx $iRet = RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", _ StringTrimLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1)), "REG_DWORD", $FEATURE_BROWSER_EMULATION) Return SetError(@error, 1, ($iRet = 1 ? $FEATURE_BROWSER_EMULATION : $iRet)) EndIf Return $iRet EndFunc ;==>_IESetEmbeddedBrowserEmulation Example() Func Example() ; https://www.autoitscript.com/forum/topic/203209-_iesetEmbeddedBrowserEmulation/ _IESetEmbeddedBrowserEmulation(0) ; remove setting. It'll default to IE 7. ;~ _IESetEmbeddedBrowserEmulation() ; set default to available IExplorer in the OS. ConsoleWrite("_IEGetEmbeddedBrowserEmulation(): " & _IEGetEmbeddedBrowserEmulation() & @CRLF) Local $oIE = _IECreateEmbedded() _IEErrorHandlerRegister() ; this is here so CheckError() get to kick in 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) Local $idButton_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30) Local $idButton_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30) Local $idButton_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) Local $idButton_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30) Global $g_idError_Message = GUICtrlCreateLabel("", 100, 500, 500, 30, -1, 0) GUICtrlSetColor(-1, 0xff0000) GUISetState(@SW_SHOW) ;Show GUI _IENavigate($oIE, "https://www.w3schools.com/js/tryit.asp?filename=tryjs_ajax_suggest_php") _IEAction($oIE, "stop") While 1 Local $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ExitLoop Case $iMsg = $idButton_Home _IENavigate($oIE, "https://www.w3schools.com/js/tryit.asp?filename=tryjs_ajax_suggest_php") _IEAction($oIE, "stop") CheckError("Home", @error, @extended) Case $iMsg = $idButton_Back _IEAction($oIE, "back") CheckError("Back", @error, @extended) Case $iMsg = $idButton_Forward _IEAction($oIE, "forward") CheckError("Forward", @error, @extended) Case $iMsg = $idButton_Stop _IEAction($oIE, "stop") CheckError("Stop", @error, @extended) EndSelect WEnd GUIDelete() EndFunc ;==>Example Func CheckError($sMsg, $iError, $iExtended) If $iError Then $sMsg = "Error using " & $sMsg & " button (" & $iExtended & ")" Else $sMsg = "" EndIf GUICtrlSetData($g_idError_Message, $sMsg) EndFunc ;==>CheckError if within a week no one came up with better code, I'll add these 2 functions to the trac, to be evaluated for adding it to IE.au3 on a next beta oh, ..do uncomment the _IESetEmbeddedBrowserEmulation() to see the difference between declared emulation and not. Your ideas are very much welcomed. PS: for now I guess this code is just an example. 6/27/2020 update: To look for the IE version and use that as the Default value. This way if you have, say v10.x.x.x, it will not try to emulate v11. The default browser value is the Int(version) & "000", so it does not need a lookup a table. Tested on XP, Win7 and Win10. 6/28/2020 update: Renamed the functions from *BrowserEmulation() to * EmbeddedBrowserEmulation() as it truly only applies to an Embedded Browser. Also changed the Version discovery form looking at the EXE to looking at the DLL. ( all this thanks to @Chimp's clues )