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.
Proxy Support Help Needed
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: Proxy Support Help Needed
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"
Re: Proxy Support Help Needed
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
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: Proxy Support Help Needed
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.
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.
Re: Proxy Support Help Needed
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.
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: Proxy Support Help Needed
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.
Re: Proxy Support Help Needed
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.
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.
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: Proxy Support Help Needed
.. 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.
Re: Proxy Support Help Needed
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.
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.