Electon Posted December 6, 2010 Share Posted December 6, 2010 (edited) Hello everyone. I have figured out how to change things such as the user agent when using an embedded IE object in my autoit applications (thanks to some code I found around here). Here is my code to change user agents:Func userAgent($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) EndFuncWhich works perfectly. Now I have a great need to set the proxy settings in this way. I am no pro at using DLLs though. The documentation for the DLL is here: http://msdn.microsoft.com/en-us/library/ms775125(VS.85).aspx and has proxy options but I can't figure out how to do it. I would be extremely greatfull if someone could show me how to set http and socks proxies using this dll. Thank you. Edited December 6, 2010 by Electon Link to comment Share on other sites More sharing options...
Electon Posted December 7, 2010 Author Share Posted December 7, 2010 anyone? i could really use some help. Link to comment Share on other sites More sharing options...
Electon Posted December 8, 2010 Author Share Posted December 8, 2010 If anyone can solve this I will paypal them. This is very important to me. Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 8, 2010 Share Posted December 8, 2010 Func _SetProxy($proxy, $proxybypass = "") Local INTERNET_OPTION_PROXY = 38; Local INTERNET_OPEN_TYPE_PROXY = 3; Local $tBuff = DllStructCreate("dword;ptr;ptr") DllStructSetData($tBuff, 1, INTERNET_OPEN_TYPE_PROXY) Local $pproxy = DllStructCreate("char[" & (StringLen($proxy) + 1) & "]") DllStructSetData($pproxy, 1, $proxy) DllStructSetData($tBuff, 2, DllStructGetPtr($pproxy)) Local $pproxybypass = DllStructCreate("char[" & (StringLen($proxybypass) + 1) & "]") DllStructSetData($pproxybypass, 1, $proxybypass) DllStructSetData($tBuff, 3, DllStructGetPtr($pproxybypass)) $chk_UrlMkSetSessionOption = DllCall("urlmon.dll", "long", "UrlMkSetSessionOption", "dword", INTERNET_OPTION_PROXY, "ptr", DllStructGetPtr($tBuff), "dword", DllStructGetSize($tbuff), "dword", 0) EndFunc I believe this should work. It is untested though. Let me know what happens. Link to comment Share on other sites More sharing options...
Electon Posted December 8, 2010 Author Share Posted December 8, 2010 Func _SetProxy($proxy, $proxybypass = "") Local INTERNET_OPTION_PROXY = 38; Local INTERNET_OPEN_TYPE_PROXY = 3; Local $tBuff = DllStructCreate("dword;ptr;ptr") DllStructSetData($tBuff, 1, INTERNET_OPEN_TYPE_PROXY) Local $pproxy = DllStructCreate("char[" & (StringLen($proxy) + 1) & "]") DllStructSetData($pproxy, 1, $proxy) DllStructSetData($tBuff, 2, DllStructGetPtr($pproxy)) Local $pproxybypass = DllStructCreate("char[" & (StringLen($proxybypass) + 1) & "]") DllStructSetData($pproxybypass, 1, $proxybypass) DllStructSetData($tBuff, 3, DllStructGetPtr($pproxybypass)) $chk_UrlMkSetSessionOption = DllCall("urlmon.dll", "long", "UrlMkSetSessionOption", "dword", INTERNET_OPTION_PROXY, "ptr", DllStructGetPtr($tBuff), "dword", DllStructGetSize($tbuff), "dword", 0) EndFunc I believe this should work. It is untested though. Let me know what happens. Thank you. In what format should I pass the proxy/port to it? also, will it accept SOCKS5? I will paypal you for this help you're giving me. thank you so much. Link to comment Share on other sites More sharing options...
Electon Posted December 8, 2010 Author Share Posted December 8, 2010 Func _SetProxy($proxy, $proxybypass = "") Local $INTERNET_OPTION_PROXY = 38 Local $INTERNET_OPEN_TYPE_PROXY = 3 Local $tBuff = DllStructCreate("dword;ptr;ptr") DllStructSetData($tBuff, 1, $INTERNET_OPEN_TYPE_PROXY) Local $pproxy = DllStructCreate("char[" & (StringLen($proxy) + 1) & "]") DllStructSetData($pproxy, 1, $proxy) DllStructSetData($tBuff, 2, DllStructGetPtr($pproxy)) Local $pproxybypass = DllStructCreate("char[" & (StringLen($proxybypass) + 1) & "]") DllStructSetData($pproxybypass, 1, $proxybypass) DllStructSetData($tBuff, 3, DllStructGetPtr($pproxybypass)) $chk_UrlMkSetSessionOption = DllCall("urlmon.dll", "long", "UrlMkSetSessionOption", "dword", $INTERNET_OPTION_PROXY, "ptr", DllStructGetPtr($tBuff), "dword", DllStructGetSize($tbuff), "dword", 0) EndFunc there was a syntax error in there i fixed with those local variables. I tried to pass the function the SOCKS proxy in the form of ip:port and then the page wouldn't load. Link to comment Share on other sites More sharing options...
Electon Posted December 8, 2010 Author Share Posted December 8, 2010 okay I passed it an HTTP proxy and that worked. now just need to figure out how to use SOCKS. Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 8, 2010 Share Posted December 8, 2010 (edited) I'm not familiar with the code at all. I merely translated it from MSDN. I'll look around and see what I can find on SOCKS proxy. Ok, pass the parameter like "socks=127.0.0.1:12345" And replace the IP and port with whatever you have. Edited December 8, 2010 by Richard Robertson Link to comment Share on other sites More sharing options...
Electon Posted December 8, 2010 Author Share Posted December 8, 2010 I'm not familiar with the code at all. I merely translated it from MSDN. I'll look around and see what I can find on SOCKS proxy.Ok, pass the parameter like "socks=127.0.0.1:12345" And replace the IP and port with whatever you have.nice. I had tried that before and it didn't work (im used to the registry setting). the SOCKS i was using must have died because its working now. Thank you. PM me your paypal addy if you intend to collect a reward. Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 8, 2010 Share Posted December 8, 2010 No reward needed. I only helped because I understand translating structs from the MSDN can be difficult for languages like AutoIt. Link to comment Share on other sites More sharing options...
Electon Posted December 9, 2010 Author Share Posted December 9, 2010 No reward needed. I only helped because I understand translating structs from the MSDN can be difficult for languages like AutoIt.would you consider writing a tutorial on doing it in autoit? being able to do this greatly extends what can be done. Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 9, 2010 Share Posted December 9, 2010 There are plenty of tutorials. I don't even use AutoIt as a language anymore, so there's not much point in me writing a tutorial. Link to comment Share on other sites More sharing options...
drego Posted December 10, 2013 Share Posted December 10, 2013 It's easy. Just prepend socks= to the ip/port 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