microsoft.xmlhttp是鸡肋,没有setTimeouts,弃之
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $OEvent = ObjEvent("AutoIt.Error", "MyErrFunc")
Global Const $NETWORK_ALIVE_LAN = 0x1
Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 202, 174, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$LabelER = GUICtrlCreateLabel("Label1", 24, 24, 140, 33)
$Button1 = GUICtrlCreateButton("Button1", 24, 96, 145, 41)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func Button1Click()
;$x = DllCall("sensapi.dll", "int", "IsNetworkAlive", "str", $NETWORK_ALIVE_LAN)
;If $x[0] = 1 Then
$oHTTP.Open("POST", "http://10.231.49.241/baseweb/loginAction.do", True)
$oHTTP.setTimeouts(1000, 1000, 1000, 1000)
$oHTTP.setRequestHeader("Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*")
$oHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.setRequestHeader("Accept-Encoding", "gzip, deflate")
$oHTTP.setRequestHeader("Accept-Language", "zh-cn")
;$oHTTP.setRequestHeader("Cookie", $PCCOOKIE)
$oHTTP.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)")
$oHTTP.Send("name=lywgh&password=123456&Submit= ?&version=20100529")
$oHTTP.WaitForResponse
If @error Then
Return MsgBox(0, "错误", "超时")
EndIf
If StringInStr($oHTTP.responseText, 'id="mainFrame"') = 0 Then
MsgBox(0, "错误", "用户名密码错误,请修改!")
Run(@ScriptName)
Sleep(300)
Return
Else
;$PCCOOKIE = "visitname=" & $Zhanghao & ";" & "JSESSIONID=" & _getString($oHTTP.GetAllResponseHeaders(), "JSESSIONID=")
GUICtrlSetData($LabelER, "登录成功")
EndIf
; Else
; GUICtrlSetData($LabelER, "网络不通。。。")
;EndIf
EndFunc ;==>Button1Click
Func Form1Close()
Exit
EndFunc ;==>Form1Close
Func MyErrFunc()
EndFunc ;==>MyErrFunc
|