AutoHotkey-Util
AutoHotkey-Util copied to clipboard
BrowserEmulation (FixIE) Minor Issues
Hey @cocobelgica Got this from the old thread. The 6432Node bit doesn't apply- see this and the following answer- + cannot jump out of finally block any more. Here's a modded version of it that addresses just those (sorry- fixated on FixIE as everyone else seemed to be): Edit: also modded the "version := Round..." line where, previously, existing reg entries greater than 1000 would be multiplied by 1000 again.
``
``FixIE(version:="*") ;// FEATURE_BROWSER_EMULATION -> http://goo.gl/V01Frx
{
static key := "HKCU\Software\"
. "Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\"
. ( A_IsCompiled ? A_ScriptName : StrGet(DllCall("Shlwapi\PathFindFileName", "Str", A_AhkPath)) )
static WshShell := ComObjCreate("WScript.Shell")
static prev := "*"
if (prev == "*") ;// init
try prev := WshShell.RegRead(key)
catch ;// value does not exist
prev := ""
;// __Get()
if (version == "*")
{
try val := WshShell.RegRead(key)
catch ;// value does not exist
{
val := "" ;// throw Exception()??
}
return val
}
;// __Set()
ie_version := Round(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Internet Explorer\svcVersion"))
if (ie_version < 8) ;// unsure of this but I read it somewhere...
throw Exception("FEATURE_BROWSER_EMULATION is only available for IE8 and later.")
if version
{
if !(version ~= "i)^7|-?(8|9|1[01])|edge$")
throw Exception(Format("Invalid argument: '{1}'", version))
if (version = "edge")
version := ie_version
version := Round(version * (version>0 ? ((version>=1000)? 1 : 1000) : -(version>=-9 ? 1111 : 1000.1)))
}
try version? WshShell.RegWrite(key, version, "REG_DWORD")
: (prev != "" ? WshShell.RegWrite(key, prev, "REG_DWORD") : WshShell.RegDelete(key))
catch error
{
throw error
}
return FixIE() ;// OR return the value itself
}
Thanks.