Proxy Support Help Needed

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ecksphore
Posts: 33
Joined: 03 Feb 2015, 22:36

Proxy Support Help Needed

25 Jun 2016, 22:26

I'm on the road a lot and I've created a script that automates a whole bunch of work using a web browser control. Going forward, I am now required to connect to my work's proxy server before I can do anything.

This issue I am having is that it requires authentication, and I can't figure out how to automate sending the proxy username and password in a WB control.

Any pointers would be greatly appreciated.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Proxy Support Help Needed

26 Jun 2016, 00:01

I assume you mean you're using InternetExplorer.Application via COM? You find and set the controls directly. Example:

Code: Select all

wb.getElementByID("Username"):="My Username"

wb.getElementsByClassName("Password")[0]:="My Password"
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
ecksphore
Posts: 33
Joined: 03 Feb 2015, 22:36

Re: Proxy Support Help Needed

26 Jun 2016, 00:13

Yes I am, Thank you. Is this the only way to set it? The authentication box pops up so randomly (sometimes takes a minute before I see it). I noticed this can be done with a DLL call as well - any way to log in to the proxy and send auth with this method?

Code: Select all

https://msdn.microsoft.com/en-us/library/windows/desktop/aa385328(v=vs.85).aspx#INTERNET_OPTION_PROXY_USERNAME
https://msdn.microsoft.com/en-us/library/windows/desktop/aa385328(v=vs.85).aspx#INTERNET_OPTION_PROXY_PASSWORD
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Proxy Support Help Needed

26 Jun 2016, 00:33

Sure, by, as you said, using DllCall. Direct it at InternetSetOption with the correct parameters, and that should be it. You can call it again to remove the proxy after whatever operations you have running finish. And by the looks of it, you should set this before you connect to the object, or at least before you get to the page. I've never worked with proxies, so not sure.

If it requires authentication in the form of a popup even after you've connected that way, not sure what to do about that. ControlSend, I suppose.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
ecksphore
Posts: 33
Joined: 03 Feb 2015, 22:36

Re: Proxy Support Help Needed

26 Jun 2016, 10:51

Would it be possible for you to give me an example how to make the DLL Call for this? I'm not too familiar with how to set the parameters for it.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Proxy Support Help Needed

26 Jun 2016, 11:11

Untested. Replace username and password with your credentials before running.

Code: Select all

username:="Who"
password:="Is"

; connect IE
wb:=comObjCreate("InternetExplorer.Application")

; set proxy
varSetCapacity(sOp)
strPut(username,sOp,strLen(username))
u1:=dllCall("Wininet.dll\InternetSetOption","UInt",wb,"Int",43,"Ptr",sOp,"Int",strLen(username))
strPut(password,sOp,strLen(password))
p1:=dllCall("Wininet.dll\InternetSetOption","UInt",wb,"Int",44,"Ptr",sOp,"Int",strLen(password))

; operations

; set blank proxy/reset
strPut("",sOp)
u2:=dllCall("Wininet.dll\InternetSetOption","UInt",wb,"Int",43,"Ptr",sOp,"Int",0)
p2:=dllCall("Wininet.dll\InternetSetOption","UInt",wb,"Int",44,"Ptr",sOp,"Int",0)

; disconnect IE
try wb.quit()

; report returned codes from dllcalls ; 1 = successful, 0 = failed
msgbox,,Exit codes,% "Set username: " u1 "`tSet password: " p1 "`nSet username: " u2 "`tSet password: " p2
exitApp
Last edited by Masonjar13 on 26 Jun 2016, 14:01, edited 1 time in total.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
ecksphore
Posts: 33
Joined: 03 Feb 2015, 22:36

Re: Proxy Support Help Needed

26 Jun 2016, 13:50

This looks great, but unfortunately does not work for me. I'm still prompted for a username & password. All 4 exit codes were blank. On a off note, I noticed your DLL calls sets the user/pass for "WB" only - is there a DLL call that can also set the IP address & port for "WB" only as well?

My current solution uses the windows registry, which unfortunately effects both IE and Edge browser. It would be great to adapt that to "WB" only as well.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Proxy Support Help Needed

26 Jun 2016, 14:03

.. Well that's embarrassing. Of course it's returning 0, I didn't didn't give it the function to call. I edited the code in my previous post, try it again and see how that works. Although, I'm not sure that the COM object is valid to reference there, so it may not work still.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
ecksphore
Posts: 33
Joined: 03 Feb 2015, 22:36

Re: Proxy Support Help Needed

28 Jun 2016, 11:03

I'm sorry for the delay. I just checked and still getting prompted for a username / password and it's still returning 0.

I have private proxies that your more than welcome to if you would like to test on your end (just in case I'm doing something wrong?). I can PM them to you.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, mcd, Nerafius, RandomBoy, Rohwedder and 102 guests