本帖最后由 auto 于 2012-4-15 08:49 编辑
参考VB设置代理的代码转成换AU3,总是失败。无法显示网页。
如修改注册设置代理却是可以的,不问题出在哪
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include<IE.au3>
Global $ProxyServer ='http=113.106.194.220:80'
Global Const $tagWINHTTP_PROXY_INFO = "DWORD dwAccessType;ptr lpszProxy;ptr lpszProxyBypass;"
Global Const $INTERNET_OPTION_PROXY = 38
Global Const $INTERNET_OPTION_SETTINGS_CHANGED = 39
Global Const $INTERNET_OPEN_TYPE_DIRECT = 1
Global Const $INTERNET_OPEN_TYPE_PROXY = 3
$xl = GUICreate("test", 1000, 500) ;
GUISetState(@SW_SHOW)
$ProxyInfo = ProxyInfoCreate($INTERNET_OPEN_TYPE_PROXY, $ProxyServer, "") ;
DllCall("wininet.dll", 'long', 'InternetSetOption', "long", 0, 'long', $INTERNET_OPTION_PROXY, 'ptr', DllStructGetPtr($ProxyInfo[0]), 'int', DllStructGetSize($ProxyInfo[0]))
DllCall("wininet.dll", 'long', 'InternetSetOption', 'long',0, 'long', $INTERNET_OPTION_SETTINGS_CHANGED, 'ptr',0, 'int', 0)
Sleep(1000)
$oIE = _IECreateEmbedded()
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 1100, 500)
$hOpen = GUICtrlGetHandle($GUIActiveX)
$R = _IENavigate ($oIE, "http://ip.chinaz.com",0)
Sleep(5000)
$R = _IENavigate ($oIE, "http://www.cz88.net/ip/viewip468.aspx",0)
While 1
Sleep(10)
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $GUI_EVENT_MINIMIZE
Exit
Case $msg = $GUI_EVENT_MAXIMIZE
Exit
EndSelect
WEnd
Func ProxyInfoCreate($dwAccessType, $sProxy, $sProxyBypass)
Local $tWINHTTP_PROXY_INFO[2] = [DllStructCreate($tagWINHTTP_PROXY_INFO), DllStructCreate('wchar proxychars[' & StringLen($sProxy)+1 & ']; wchar proxybypasschars[' & StringLen($sProxyBypass)+1 & ']')]
DllStructSetData($tWINHTTP_PROXY_INFO[0], "dwAccessType", $dwAccessType)
If StringLen($sProxy) Then DllStructSetData($tWINHTTP_PROXY_INFO[0], "lpszProxy", DllStructGetPtr($tWINHTTP_PROXY_INFO[1], 'proxychars'))
If StringLen($sProxyByPass) Then DllStructSetData($tWINHTTP_PROXY_INFO[0], "lpszProxyBypass", DllStructGetPtr($tWINHTTP_PROXY_INFO[1], 'proxybypasschars'))
DllStructSetData($tWINHTTP_PROXY_INFO[1], "proxychars", $sProxy)
DllStructSetData($tWINHTTP_PROXY_INFO[1], "proxybypasschars", $sProxyBypass)
Return $tWINHTTP_PROXY_INFO
EndFunc
|