Ranger08 Posted June 18, 2012 Share Posted June 18, 2012 (edited) My goal is to change the user agent for internet explorer to something else (for the whole process/session and not just one page). Been searching and haven't found a clear answer as to how to do this, if anyone can give me a little helping hand I'd appreciate it, thanks.Tried, but didn't work out well for me (can't say I really understood it in the first place though): Code I'm working with#include <IE.au3> $URL = "http://google.com" $URL2 = "http://youtube.com" $OIE = _IECREATE("http://msn.com") _IENAVIGATE($OIE, $URL, $URL2) Edited June 18, 2012 by Ranger08 Link to comment Share on other sites More sharing options...
Skitty Posted June 18, 2012 Share Posted June 18, 2012 (edited) Try doing it like this. Local $sUserAgent = "Agent User 1.0" Local $skey = "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings" If @OSArch <> "X86" And @AutoItX64 Then $skey = "HKEY_CURRENT_USER64SoftwareMicrosoftWindowsCurrentVersionInternet Settings" Local $Write = RegWrite($skey, "User Agent", "REG_SZ", $sUserAgent) If Not $Write Then Exit MsgBox(16, "Error!", "Something went wrong while trying to set the useragent.") DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) Edit: Do not run the first one, I remembered the data type of that key, this one is correct. Edited June 18, 2012 by ApudAngelorum Link to comment Share on other sites More sharing options...
Ranger08 Posted June 18, 2012 Author Share Posted June 18, 2012 (edited) Thanks for the reply, didn't work for me, here's the exact code i used #include <IE.au3> $URL = "http://google.com" $URL2 = "http://youtube.com" $OIE = _IECREATE("http://whatsmyuseragent.com") Local $sUserAgent = "Agent User 1.0" Local $skey = "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings" If @OSArch <> "X86" And @AutoItX64 Then $skey = "HKEY_CURRENT_USER64SoftwareMicrosoftWindowsCurrentVersionInternet Settings" Local $Write = RegWrite($skey, "User Agent", "REG_SZ", $sUserAgent) If Not $Write Then Exit MsgBox(16, "Error!", "Something went wrong while trying to set the useragent.") DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) _IENAVIGATE($OIE, $URL, $URL2) Edited June 18, 2012 by Ranger08 Link to comment Share on other sites More sharing options...
Skitty Posted June 18, 2012 Share Posted June 18, 2012 #include <IE.au3> Local $URL = "http://google.com" Local $URL2 = "http://youtube.com" Local $sUserAgent = "Agent User 1.0" Local $skey = "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings" If @OSArch <> "X86" And @AutoItX64 Then $skey = "HKEY_CURRENT_USER64SoftwareMicrosoftWindowsCurrentVersionInternet Settings" Local $Write = RegWrite($skey, "User Agent", "REG_SZ", $sUserAgent) If Not $Write Then Exit MsgBox(16, "Error!", "Something went wrong while trying to set the useragent.") DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) $OIE = _IECREATE("http://whatsmyuseragent.com") Sleep (500000) _IENAVIGATE($OIE, $URL, 1) Now? El-Masry 1 Link to comment Share on other sites More sharing options...
Ranger08 Posted June 18, 2012 Author Share Posted June 18, 2012 (edited) Thanks Checked regedit and saw that the change was applied to the user agent, don't know why none of the sites I use to check the user agent aren't showing the change. Tried flushing DNS/Cache, same result. Could there possibly be an alternative way? Edited June 18, 2012 by Ranger08 Link to comment Share on other sites More sharing options...
Skitty Posted June 18, 2012 Share Posted June 18, 2012 Maybe look into IEs settings, it must not be using system proxy settings. 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