-- script "netOp.ProxyHelper" --@ version 1.0.0 --@ Use 'CheckProxy(protocol)' to attempt to automatically configure the proxy for HTTP, Otherwise, use -- 'ConfigureProxy (proxyAddress, portNum, protocol) --@Dependencies -- BuddyAPI Xtra (for reading the registry) --- STATIC SCRIPT PROPERTIES -------------------------------------- property ProxyConfigured -- PUBLIC ----------- on new (me) return me.script end on CheckProxy (this, src, doItAgain) if voidP(src) then src = #http this._CheckInit() if this.ProxyConfigured[src] = 1 AND NOT(doItAgain) then return "Proxy already configured" -- already done -- try and auto configure if (the platform) contains "Mac" then -- Mac (need to do) return ("Unable to determine Proxy settings") else -- Windows useProxy = baReadRegNumber("Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyEnable", 0, "HKEY_CURRENT_USER") if useProxy then NetStatusUpdate("Proxy enabled") proxyInfo = baReadRegString("Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer", "Error", "HKEY_CURRENT_USER" ) if proxyInfo <> "Error" then if (proxyInfo contains ";") then proxyInfo = this._ExtractProxyInfo(proxyInfo, src) end if the itemDelimiter = ":" proxyAddress = proxyInfo.item[1] portNum = value(proxyInfo.item[2]) if proxyAddress <> "" then proxyServer(src, proxyAddress, portNum) this.ProxyConfigured[src] = 1 return ("Proxy Configured: " & proxyAddress & ": " & portNum) else return ("Unable to determine Proxy settings") end if else return ("Unable to determine Proxy settings") end if end if return ("Proxy not enabled") end if end on ConfigureProxy (this, proxyAddress, portNum, src) this._CheckInit() if voidP(src) then src = #http this.ProxyConfigured[src] = 1 proxyServer(src, proxyAddress, portNum) end -- PRIVATE ----------- on _ExtractProxyInfo (this, str, src) src = string(src) aList = explode(";", str) the itemDelimiter = "=" repeat with anEntry in aList if anEntry.item[1] = src then return anEntry.item[2] end repeat if src <> "HTTP" then -- look for that instead return this._ExtractProxyInfo(str, #Http) end if return "" end on _CheckInit (this) if voidP(this[#ProxyConfigured]) then this[#ProxyConfigured] = [:] end