ktoya Posted March 27, 2014 Share Posted March 27, 2014 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? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 27, 2014 Share Posted March 27, 2014 Maybe this function will do it for you - http://www.autoitscript.com/autoit3/docs/functions/HttpSetUserAgent.htm - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
ktoya Posted March 27, 2014 Author Share Posted March 27, 2014 Maybe this function will do it for you - http://www.autoitscript.com/autoit3/docs/functions/HttpSetUserAgent.htm the function is for inet requests, I need to browse the website by IE Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 27, 2014 Share Posted March 27, 2014 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. Link to comment Share on other sites More sharing options...
ktoya Posted March 28, 2014 Author Share Posted March 28, 2014 I know what it says in the Help file. And I know why I said 'maybe'. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now