Jump to content
Sign in to follow this  
ktoya

IE user agent

Recommended Posts

ktoya
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()
_SetUserAgent("test")
GUICtrlCreateObj($oIE1, 8, 6, 599, 177)

GUISetState(@SW_SHOW)

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

_IELoadWait($oIE1,1000,10000)

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
 Case $GUI_EVENT_CLOSE
Exit

   EndSwitch
WEnd


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)
 EndFunc
 
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
somdcomputerguy

I know what it says in the Help file. And I know why I said 'maybe'. :)


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
ktoya

I know what it says in the Help file. And I know why I said 'maybe'. :)

:

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  

×