Tested and working on IE 7, 8.
To change the User Agent in later versions of IE, see the posts below
Typical default User Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0
Call the function after creating the COM Object and before the Navigate() or Navigate2() methods.
Or you can call it from a BeforeNavigate2() Event or Class Event.
Examples:
Code: Select all
; Switch from IE to Safari User Agent
_SetUserAgent("Windows; U; Windows NT 6.1; tr-TR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27")
Code: Select all
; Switch from IE to Opera User Agent
_SetUserAgent("Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14")
Code: Select all
; Fun nonsense
_SetUserAgent("kittens like this User Agent")
Code: Select all
_SetUserAgent(dwOpt)
{
; Discovered by Inthemist
; AutoIt >> AutoHokey port by TLM
; ANSI fix by GeekDude
DllCall("urlmon.dll\UrlMkSetSessionOption"
, uint, 0x10000001
, aStr, dwOpt
, uint, StrLen(dwOpt)
, uint, 0)
}
as Navigate/2() headers only work once.
You can verify the User Agent by navigating to: http://whatsmyuseragent.com