Jump to content

How to change Proxy settings?


Recommended Posts

Hello, everyone. First of all, my AutoIt Version 3.2.12.1

I searched AutoIt Help File and Forum, and I found two way using proxy setting.

1) HttpSetProxy

This is convienent but I found remarks in Help file.

Only CERN proxy servers are supported.

And it not applied _INetGetSource()

2) WinHttp.WinHttpRequest.5.1

This also not applied _INetGetSource(), but it uses simple code and UDF.

Proxy setting & Using example

Global $oHttp = ObjCreate ("WinHttp.WinHttpRequest.5.1");
              $oHttp.SetProxy(2,"0.0.0.0:80");
              $text = httpget($Url);

httpget Func

func httpget($url)
    $COMerrnotify = false
    
    If $UseIntegratedSecurity Then
        $oHttp.SetAutoLogonPolicy(0); Always = 0, OnlyIfBypassProxy = 1, Never = 2
    Else
        $oHttp.SetAutoLogonPolicy(2); Always = 0, OnlyIfBypassProxy = 1, Never = 2
    EndIf
    
    $status = $oHttp.Open("GET", $url,false)
    
    If Not $UseIntegratedSecurity Then
        $oHttp.SetCredentials($ProxyUser,$ProxyPass,0); HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0
    EndIf
        
    $oHttp.Send()
    if $oHttp.Status <> "200" then
        $status = $oHttp.Status
        $StatusText = $oHttp.StatusText
        Consolewrite("Status: " & $status & @crlf)
        Consolewrite("StatusText: " & $StatusText & @crlf)
        $COMerrnotify = true
        SetError(1)
        return $status & " - " & $StatusText        
    Else
        $COMerrnotify = true
        SetError(0)
        Consolewrite("Response Headers: " & $oHttp.GetAllResponseHeaders & @crlf)
        return $oHttp.ResponseText
    EndIf
EndFunc

$oIEErrorHandler = ObjEvent("AutoIt.Error","ComErrFunc")
global $COMerrnotify = true
Func ComErrFunc()
    If IsObj($oIEErrorHandler) Then
        if $COMerrnotify then
            ConsoleWrite("--> ComErrFunc: COM Error Encountered in " & @ScriptName & @CR)
            ConsoleWrite("----> Scriptline = " & $oIEErrorHandler.scriptline & @CR)
            ConsoleWrite("----> Number Hex = " & Hex($oIEErrorHandler.number, 8) & @CR)
            ConsoleWrite("----> Number = " & $oIEErrorHandler.number & @CR)
            ConsoleWrite("----> Win Description = " & StringStripWS($oIEErrorHandler.WinDescription, 2) & @CR)
            ConsoleWrite("----> Description = " & StringStripWS($oIEErrorHandler.description, 2) & @CR)
            ConsoleWrite("----> Source = " & $oIEErrorHandler.Source & @CR)
            ConsoleWrite("----> Help File = " & $oIEErrorHandler.HelpFile & @CR)
            ConsoleWrite("----> Help Context = " & $oIEErrorHandler.HelpContext & @CR)
            ConsoleWrite("----> Last Dll Error = " & $oIEErrorHandler.LastDllError & @crlf)
        EndIf
        $HexNumber = Hex($oIEErrorHandler.number, 8)
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc

It seems to well. But, sometimes it corrupted and send this message.

:\AdBot.au3 (150) : ==> The requested action with this object has failed.:
     $oHttp.Send()
     $oHttp.Send()^ ERROR

Simply,

1) How can i set proxy server(non-CERN) for _INetGetSource()?

2) If it is unavailable, How can i do it?

Help plz~~~~~

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...