Sign in to follow this  
Followers 0
icu

[Solved] Forcing IE9 into IE8 Browser Mode?

9 posts in this topic

#1 ·  Posted (edited)

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

#2 ·  Posted (edited)

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

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

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

#6 ·  Posted (edited)

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

@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

#8 ·  Posted (edited)

@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

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  
Followers 0

  • Similar Content

    • Dent
      By Dent
      As the title says. I open IE11 and navigate to a page with the following HTML5 file upload container in Capture0.JPG
      I want to click Add Files but I haven't been able to. Here's the code that handles the Add Files button in Capture.JPG
      _IEGetObjectById and then using _IEAction to click it doesn't work. I can't give access to the actual page unfortunately because it's password protected.
      All suggestions welcome.


    • milos83
      By milos83
      I have one script that creates _IECreateEmbedded and another script that does _IEAttach.
      I do this because when autoit is doing something, the Embedded IE starts stalling (eg jquery progress animation)
      But there is a new problem.
      When IE is having its own process (like in the example above) any _IE command is slow (in the script that Attaches).
      Here is a comparison of when its in separate and when its in same process:
      Separate process _IETagNameGetCollection : 5000ms
      Separate process _IEAction: 850ms
      Same process _IETagNameGetCollection : 1ms
      Same proccess _IEAction: 135ms
       
      If I try to attach to an embedded IE that is done in c#, I get lightning fast results.
      As you can see, _IE functions work very slow when the embedded IE we are attaching to is made in Autoit.
       
      I did a test and if I empty the WHILE loop in IE process I get these results(but the cpu is at 30% as expected):
      Separate process _IETagNameGetCollection : 33ms
      Separate process _IEAction: 13ms
       
      It slows down if you put anything (like GUIGetMsg) in the WHILE loop.
       
      How do I fix this?
       
      Create IE:
      #include <GUIConstantsEx.au3> #include <IE.au3> #include <WindowsConstants.au3> Local $oIE = _IECreateEmbedded() GUICreate("My Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE, 10, 40, 600, 360) GUISetState(@SW_SHOW) ;Show GUI _IENavigate($oIE, "http://www.autoitscript.com") $timer = TimerInit() $oLink = _IETagNameGetCollection($oIE, "a", 3) ;takes 1ms ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() _IEAction($oLink, "click") ;takes 135ms ConsoleWrite(TimerDiff($timer) & @CRLF) While 1 Local $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd  
      Attach to IE:
      #include <IE.au3> Local $oIE = _IEAttach("My Embedded Web control Test", "embedded") $timer = TimerInit() $oLink = _IETagNameGetCollection($oIE, "a", 3) ; 5000ms ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() _IEAction($oLink, "click") ; 850ms ConsoleWrite(TimerDiff($timer) & @CRLF)  
       
      attach.au3
      create.au3
    • nassausky
      By nassausky
      Hi all,
       
      Anyone have any idea how to close all open tabs except a specific one I manually open.  Assuming I don't know what is open in all the tabs except just the one I want to keep open.
       
      I didn't want to use sendkeys and I was trying to use the following code to list the title (or url) of the 3 open tabs and  after I got that part working I would just close the other 2. This sample only displays the title of the first open tab
      #include <IE.au3> Const $ie_new_in_tab = 0x0800 $oIE = _IECreate("https://www.autoitscript.com") __IENavigate($oIE, "https://www.autoitscript.com/forum/", 1, $ie_new_in_tab) ;(obj,url,wait,param) __IENavigate($oIE, "https://www.google.com/", 1, $ie_new_in_tab) ;(obj,url,wait,param) Local $aIE[1] $aIE[0] = 0 Local $i = 1, $oIE While 1     $oIE = _IEAttach("", "instance", $i)     If @error = $_IEStatus_NoMatch Then ExitLoop     ConsoleWrite(_IEPropertyGet($oIE, "title") & @CRLF)     ReDim $aIE[$i + 1]     $aIE[$i] = $oIE ;each item holds object     $aIE[0] = $i ;first item holds count     $i += 1 WEnd MsgBox($MB_SYSTEMMODAL, "Browsers Found", "Number of browser instances in the array: " & $aIE[0]) ; This doesn't return the list of tabs in the console just the first tab  
      Thanks for any and all help
    • toto22
      By toto22
      I'm trying to click on Java Dropbox using IE. However, I'm running into problems. There is a Dropbox "Please Select" with two options "Buy" and "Sell".
      I'm able to click on a drop box (please see code below) but i'm unable to select "Buy" or "Sell"".
      Local $sMyString = "Please Select" ;############ ENTER ############# Local $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks Local $sLinkText = _IEPropertyGet($oLink, "innerText") If StringInStr($sLinkText, $sMyString) Then _IEAction($oLink, "click") ExitLoop EndIf Next  
      Please help
       
         
    • Gowrisankar
      By Gowrisankar
      Hello everyone,
      I'm working on a task where, a PDF file is opened (in IE browser) when I click a link in a website.
      I have to read the first page of the PDF to find particular strings. Can you please share some ideas?