Jump to content
Sign in to follow this  

IE user agent

Recommended Posts

I know we can change the user agent by _IECreateEmbedded() and it is permanent it wont be restored by refresh:
#include <ie.au3>
#include <GUIConstantsEx.au3>
$Form1 = GUICreate("test", 1024, 768, 192, 124)
$oIE1 = _IECreateEmbedded()
GUICtrlCreateObj($oIE1, 8, 6, 599, 177)


_IENavigate($oIE1, "http://www.enhanceie.com/ua.aspx")


While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg


Func _SetUserAgent($agent)
    $agentLen = StringLen($agent)
    Dim $tBuff = DllStructCreate("char["&$agentLen&"]")
    DllStructSetData($tBuff, 1, $agent)
    $chk_UrlMkSetSessionOption = DllCall("urlmon.dll", "long", "UrlMkSetSessionOption", "dword", 0x10000001, "ptr", DllStructGetPtr($tBuff), "dword", $agentLen, "dword", 0)
use IECreate() can also change the user agent however it will be disappeared by refresh, see below:
#include <ie.au3>
#include <GUIConstantsEx.au3>
$oIE1 = _IECreate()
__IENavigate ($oIE1, "http://www.enhanceie.com/ua.aspx/", 1, 0, "", "", "User-Agent: test" & @CRLF)

my goal is to change the user agent every time when _IECreate(). and keep this user agent for the session. any help?


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...