Jump to content
Sign in to follow this  
icu

[Solved] Forcing IE9 into IE8 Browser Mode?

Recommended Posts

icu

Right so IE9 breaks AutoIt scripts... and the Devs are working on it and the Beta may fix things.

Mean time the best 'work around' solution offered from my research of the forum is to set IE9 into an older and compatible mode for AutoIt (F12 and then select the option). Problem is I can't seem to find a UDF for setting the Browser Mode to 'IE8' and while I can set the Document Mode to IE8 (via sending Alt+8) this doesn't fix the problem of running AutoIt IE scripts. I've tried the UDF code offered at this posting however both sets of code offered does not seem to work. After spending an afternoon searching Google for solutions (and not finding anything), then experimenting with Exit's and supersonic's code, and my own stuff from scratch I've come back with nothing so this is a general shout out for help.

Does anyone have a UDF that specifically forces IE9 into IE8 Browser Mode?

Please share if you've got one that is working with IE 9.0.10 running on Win7 64bit.

I don't want to have to learn Scrapy or buy Screen Scraper Studio or use Sikuli if I already know AutoIt :-(

Edited by icu

Share this post


Link to post
Share on other sites
SmOke_N

You're being specific with Win7 x64 IE 9.0.10 .

IMO, I don't think IE.au3 should be used outside a "controlled" environment.

So... Why no just run a virtual machine with with XP or something that runs IE6/7 that you know works, instead of spending days ( = $ ) trying to figure out a total re-write of the IE.au3 library is needed?

Unless you're "FLUENT" in Javascript/Ajax/JQuery, no sense in beating the bush ( trust me! ).

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
SmOke_N

Good suggestion.

Also you could use an embedded IE perhaps, which I do not think would be IE9 either.

It follows default if you're referring to Shell.Explorer.2

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
icu

Thank you both for your replies,

@SmOke_N: Yeah a VM running legacy software is another work around idea and is a solution I found when doing my Google research. As for being specific I thought it would be best to actually state what windows and IE version AutoIt is breaking on. Of course a VM will work but I wanted a 'portable' code solution across all my PCs (WinXP, Vista and Win7)--that is, a single compiled AutoIt script that would not be Windows or IE dependent.

However since posting I may have found a solution but it needs more time and energy to test. Basically it would involve creating an account with spoon.net since they have a browser sandbox and then using AutoIt to use the command prompt to execute spoon.net and launch IE8. Once IE is launched, get AutoIt to attach to IE8 and do its thing. I don't have time now to start scripting for this but I thought I would quickly put a post up in case others are also looking for a solution right now.

Share this post


Link to post
Share on other sites
milos83

Embedded IE will fix your problem because it will be IE7 rendered (max IE8).

If you dont want embedded, here is a way to force all IE instances to render as <9

$64Bit = ""
If @ProcessorArch = "X64" Then
$64Bit = "64"
EndIf
If StringLeft(RegRead("HKLM" & $64Bit & "SOFTWAREMicrosoftInternet ExplorerVersion Vector", "IE"), 1) > 8 Then ;Check for version 9 or later


$wshNetwork = ObjCreate("WScript.Network")
$struser = $wshNetwork.Username
$objWMIService = ObjGet("winmgmts:.rootcimv2")
$objAccount = $objWMIService.Get('Win32_UserAccount.Name="' & $struser & '",Domain="' & @ComputerName & '"')
RegWrite("HKU" & $64Bit & "" & $objAccount.SID & "SoftwareMicrosoftInternet ExplorerBrowserEmulation", "AllSitesCompatibilityMode", "REG_DWORD", 1)
RegWrite("HKU" & $objAccount.SID & "SoftwareMicrosoftInternet ExplorerBrowserEmulation", "AllSitesCompatibilityMode", "REG_DWORD", 1)
EndIf

I picked it up somewhere on the forum and edited a bit.

Credits to the unknown user.

TESTED: WIN XP, WIN7, WIN8

BTW. Your avatar??

Edited by milos83

Share this post


Link to post
Share on other sites
icu

@milos83 THANK YOU SO MUCH!

However your code needs updating to change @ProcessorArch to @OSArch as per this The modified code is below if any others stumble upon this post.

$64Bit = ""
If @OSArch = "X64" Then
$64Bit = "64"
EndIf
If StringLeft(RegRead("HKLM" & $64Bit & "SOFTWAREMicrosoftInternet ExplorerVersion Vector", "IE"), 1) > 8 Then ;Check for version 9 or later
$wshNetwork = ObjCreate("WScript.Network")
$struser = $wshNetwork.Username
$objWMIService = ObjGet("winmgmts:.rootcimv2")
$objAccount = $objWMIService.Get('Win32_UserAccount.Name="' & $struser & '",Domain="' & @ComputerName & '"')
RegWrite("HKU" & $64Bit & "" & $objAccount.SID & "SoftwareMicrosoftInternet ExplorerBrowserEmulation", "AllSitesCompatibilityMode", "REG_DWORD", 1)
RegWrite("HKU" & $objAccount.SID & "SoftwareMicrosoftInternet ExplorerBrowserEmulation", "AllSitesCompatibilityMode", "REG_DWORD", 1)
EndIf

Again I can't express my gratitude for your post! Just out of interest what code modifications would need to be made to force IE from version 7 to 8 or back to 9? The code above currently sets IE to version 7 and writing to registry is beyond my knowledge of Windows. Also, what was the original forum post that you took this code from?

Lastly, my avatar pic has multilayered meanings to me. PM me if you are curious.

Kind regards,

icu

Share this post


Link to post
Share on other sites
milos83

@milos83 THANK YOU SO MUCH!

However your code needs updating to change @ProcessorArch to @OSArch as per this The modified code is below if any others stumble upon this post.

$64Bit = ""
If @OSArch = "X64" Then
$64Bit = "64"
EndIf
If StringLeft(RegRead("HKLM" &amp; $64Bit &amp; "SOFTWAREMicrosoftInternet ExplorerVersion Vector", "IE"), 1) > 8 Then ;Check for version 9 or later
$wshNetwork = ObjCreate("WScript.Network")
$struser = $wshNetwork.Username
$objWMIService = ObjGet("winmgmts:.rootcimv2")
$objAccount = $objWMIService.Get('Win32_UserAccount.Name="' &amp; $struser &amp; '",Domain="' &amp; @ComputerName &amp; '"')
RegWrite("HKU" &amp; $64Bit &amp; "" &amp; $objAccount.SID &amp; "SoftwareMicrosoftInternet ExplorerBrowserEmulation", "AllSitesCompatibilityMode", "REG_DWORD", 1)
RegWrite("HKU" &amp; $objAccount.SID &amp; "SoftwareMicrosoftInternet ExplorerBrowserEmulation", "AllSitesCompatibilityMode", "REG_DWORD", 1)
EndIf

Again I can't express my gratitude for your post! Just out of interest what code modifications would need to be made to force IE from version 7 to 8 or back to 9? The code above currently sets IE to version 7 and writing to registry is beyond my knowledge of Windows. Also, what was the original forum post that you took this code from?

Lastly, my avatar pic has multilayered meanings to me. PM me if you are curious.

Kind regards,

icu

I use @ProcessorArch because my Autoit version is old.

For reverting rendering

$64Bit = ""
If @OSArch = "X64" Then
$64Bit = "64"
EndIf

$wshNetwork = ObjCreate("WScript.Network")
$struser = $wshNetwork.Username
$objWMIService = ObjGet("winmgmts:.rootcimv2")
$objAccount = $objWMIService.Get('Win32_UserAccount.Name="' & $struser & '",Domain="' & @ComputerName & '"')
RegWrite("HKU" & $64Bit & "" & $objAccount.SID & "SoftwareMicrosoftInternet ExplorerBrowserEmulation", "AllSitesCompatibilityMode", "REG_DWORD", 0)
RegWrite("HKU" & $objAccount.SID & "SoftwareMicrosoftInternet ExplorerBrowserEmulation", "AllSitesCompatibilityMode", "REG_DWORD", 0)

Also, what was the original forum post that you took this code from?

Idk,Use search to find that post

Edited by milos83

Share this post


Link to post
Share on other sites
Wolfiesaxah

I hope this bumps this post back to the top to get respondents but I need to revive this post. Will this still work today? Does this permanently switches the browser mode to below IE9 or does it do it permanently? I need to find a way to just temporary use IE8 during the execution of Autoit Script but retain the IE9 since I have sites that requires higher than IE8.

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
Sign in to follow this  

  • Similar Content

    • SkysLastChance
      By SkysLastChance
       
      WinActivate("MEDITECH - Internet Explorer") Sleep (500) $oIE = _IEAttach("MEDITECH") $oDiv1 = _IEGetObjById($oIE, "sysmenu-searchbarbutton") _IEAction($oDiv1, "click") I am just trying to click the little magnifying glass, next to the gear button with no luck. I was hoping someone might have an idea why this is not working?
       

    • SkysLastChance
      By SkysLastChance
      I am trying to type a name in patient summary search box. How should I go about doing this. I am clearly not doing it right. (Attached Picture of HTML code.)
      This is what I have tried. I assume this is not working because it is not a form? 
      WinActivate("MEDITECH - Internet Explorer")       Sleep (500)    $oIE = _IEAttach("MEDITECH")    $oForm = _IEFormGetObjByName($oIE, "systemMenu")    $oText = _IEFormElementGetObjByName($oForm, "sysmenu-searchbarinput") _IEFormElementSetValue($oText, "Hey! This works!")
    • aiter
      By aiter
      Just want to report a warning I get when using IE udf and running from F5 in scite

      -> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
      When I look at IE.au3 I see a comment that this function has been removed as there are no more fatal errors.
       
    • aiter
      By aiter
      I created a webpage using the IE udf. Great, but then I noticed I cannot do a ctrl-F to find something on the page. 
      If I save the page then bring that page up I can find things of course.
      Its trivial really, but is there way to get the ctrl-F to work when the page is generated without resorting to having to save?
    • XinYoung
      By XinYoung
      For fun, I'm building an app that opens a webpage and refreshes it every 30 seconds.
      But once the script performs _IEAction($oIE, "refresh"), the GUI closes.
      Any help is appreciated.
       

      #include <ButtonConstants.au3>
      #include <EditConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <StaticConstants.au3>
      #include <WindowsConstants.au3>
      #include <WinAPIFiles.au3>
      #include <Array.au3>
      #include <File.au3>
      #include <Excel.au3>
      #include <DateTimeConstants.au3>
      #include <MsgBoxConstants.au3>
      #include <WinAPIShellEx.au3>
      #include <MsgBoxConstants.au3>
      #include <Date.au3>
      #include <ComboConstants.au3>
      #include <guimenu.au3>
      #include <IE.au3>
      HotKeySet("{F4}", "_Exit")
      ;Open the file(s) in the selected folder
      $extension = ".txt"
      $app2openWith = @SystemDir & "\notepad.exe"
      Func Begin()
          Global $loopTrick = 0
          #Region ### START Koda GUI section ### Form=c:\users\mchu\downloads\autoit\my code\form1.kxf
          Global $UI = GUICreate("Hit Em Up!", 256, 113, -1, -1)
          GUISetBkColor(0x000000)
          $menu = _GUICtrlMenu_GetSystemMenu($UI)
          _GUICtrlMenu_EnableMenuItem($menu, $SC_CLOSE, 1, False)
          Global $url = GUICtrlCreateInput("https://www.youtube.com/watch?v=dQw4w9WgXcQ", 81, 8, 160, 21)
          $Label1 = GUICtrlCreateLabel("Target:", 16, 8, 55, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          Global $StartBut = GUICtrlCreateButton("Start", 16, 40, 67, 25)
          GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif")
          GUICtrlSetBkColor(-1, 0x008000)
          $Label2 = GUICtrlCreateLabel("(Press F4 to Exit)", 96, 40, 8000, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          GUISetState(@SW_SHOW)
          #EndRegion ### END Koda GUI section ###
          While 1
              $UIfunc = GUIGetMsg()
              Select
                  Case $UIfunc = $GUI_EVENT_CLOSE
                      _Exit()
                  Case $UIfunc = $StartBut
                      If GUICtrlRead($url) = "" Then
                          MsgBox(48, "Um...", "Give me a target you idiot.")
                      Else
                          GUICtrlSetState($url, $GUI_DISABLE)
                          GUICtrlSetState($StartBut, $GUI_DISABLE)
                          Start()
                      EndIf
              EndSelect
          WEnd
      EndFunc   ;==>Begin
      Func Start()
          If $loopTrick = 0 Then
              Global $oIE = _IECreate(GUICtrlRead($url))
              _IELoadWait($oIE)
              Again()
          ElseIf $loopTrick = 1 Then
              Sleep(3000)
              _IEAction($oIE, "refresh")
              Sleep(3000)
              Start()
          EndIf
      EndFunc   ;==>Start
      Func Again()
          $loopTrick = 1
          Start()
      EndFunc   ;==>Again
      Func _Exit()
          Exit
      EndFunc   ;==>_Exit
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.