#include "GUIConstantsEx.au3"
#include <GuiStatusBar.au3>
#include <IE.au3>
Dim $Text, $Text2 = ""
Local $aParts[4] = [330, 470, 530, 100]
Global $DEFAULTINPUTDATA_1 = "如 www.baidu.com 或baidu.com"
Global $MARk_1 = 0, $NONEAACTIVECOLOR = 0xC0C0C0
$GUIMain = GUICreate("Test", 588, 449)
GUICtrlCreateGroup("", 5, 3, 577, 105)
GUICtrlCreateLabel("网址 Http://", 18, 26, 80, 17)
$IEAdd = GUICtrlCreateInput($DEFAULTINPUTDATA_1, 90, 20, 401, 21)
$hStatus = _GUICtrlStatusBar_Create($GUIMain)
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
GUICtrlSetColor(-1, 0xC0C0C0)
$OpenIE = GUICtrlCreateButton("打开", 500, 18, 70, 25)
GUICtrlCreateLabel("ADSL账号:", 18, 54, 68, 17)
$Adslaccount = GUICtrlCreateInput("", 90, 48, 141, 21)
GUICtrlCreateLabel("密码:", 240, 54, 40, 17)
$Adslpassword = GUICtrlCreateInput("", 280, 48, 121, 21, 0x0020)
$Adsl = GUICtrlCreateLabel("测试...", 410, 52, 35, 25)
GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetCursor(-1, 0)
GUICtrlCreateLabel("每间隔", 18, 83, 40, 17)
$TimeSec = GUICtrlCreateInput("10", 55, 79, 30, 18)
GUICtrlCreateLabel("秒, 自动刷新", 88, 83, 75, 17)
$Checkbox1 = GUICtrlCreateCheckbox("每次清除Cookies,", 168, 81, 120, 17)
GUICtrlCreateLabel("刷", 292, 83, 16, 17)
$TimeNum = GUICtrlCreateInput("", 305, 79, 49, 18)
GUICtrlCreateLabel("次停止", 355, 83, 40, 17)
$Began = GUICtrlCreateButton("开始", 450, 55, 51, 45)
$stop = GUICtrlCreateButton("停止", 516, 55, 51, 45)
GUICtrlSetState($stop, $GUI_DISABLE)
GUISetState()
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 5, 110, 577, 318)
$EventObject = ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents")
If @error Then Exit MsgBox(0, "错误!", "不可使用COM接口 'DWebBrowserEvents'. 错误代码: " & Hex(@error, 8))
While 1
$msg = GUIGetMsg()
_CheckInput($GUIMain, $IEAdd, "如 www.baidu.com 或baidu.com", $DEFAULTINPUTDATA_1, $MARk_1)
If GUICtrlRead($IEAdd) = "" Or GUICtrlRead($IEAdd) = $DEFAULTINPUTDATA_1 Then
If BitAND(GUICtrlGetState($Began), $gui_enable) Then
GUICtrlSetState($Began, $GUI_DISABLE)
EndIf
Else
If BitAND(GUICtrlGetState($Began), $GUI_DISABLE) Then
GUICtrlSetState($Began, $gui_enable)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Then
$EventObject.Stop ; 不再接收事件
$EventObject = 0 ; 关闭Event Object
$oIE = 0 ; 清除内存
GUIDelete()
Exit
EndIf
If $msg = $GUI_EVENT_MINIMIZE Then GUISetState(@SW_HIDE)
If $msg = $Began Then
GUICtrlSetState($Began, $GUI_DISABLE)
GUICtrlSetState($stop, $gui_enable)
If GUICtrlRead($TimeSec) < 5 Then
$TimeS = 5
Else
$TimeS = GUICtrlRead($TimeSec)
EndIf
AdlibReg($TimeS, GUICtrlRead($TimeNum))
EndIf
WEnd
Func IEEvent_StatusTextChange($Text)
If $Text <> '' And StringLeft($Text, 4) = "http" Then $Text2 = $Text
_GUICtrlStatusBar_SetText($hStatus, $Text)
EndFunc ;==>IEEvent_StatusTextChange
Func AdlibReg($Time, $TimeMember)
Local $t, $ti, $i = 0, $decTime = 1
Local $begin = TimerInit()
While 1
If $msg = $stop Then ExitLoop
; If $i = $TimeMember Or $TimeMember <> "" Then
; GUICtrlSetState($stop, $GUI_DISABLE)
; GUICtrlSetState($Began, $gui_enable)
; _GUICtrlStatusBar_SetText($hStatus, "已停止", 2)
; ExitLoop
; Else
$oIE.Navigate("http://" & GUICtrlRead($IEAdd))
Sleep(1000)
GUISwitch($GUIMain)
_GUICtrlStatusBar_SetText($hStatus, _GetInternetIP(), 1)
$ti = Int(TimerDiff($begin) / 1000)
MsgBox(0,$begin,$ti)
If $ti >= $decTime Then
$decTime += 1
_GUICtrlStatusBar_SetText($hStatus, $Time - $ti, 2)
Sleep($Time&"000")
EndIf
If GUICtrlRead($Adslaccount) And GUICtrlRead($Adslaccount) <> "" Then
RunWait(@ComSpec & " /c rasdial 宽带连接 /disconnect", "", 0)
RunWait(@ComSpec & " /c rasdial 宽带连接 " & GUICtrlRead($Adslaccount) & " " & GUICtrlRead($Adslpassword), "", @SW_HIDE)
EndIf
$i = $i + 1
_GUICtrlStatusBar_SetText($hStatus, $i, 3)
WEnd
EndFunc ;==>AdlibReg
Func _CheckInput($hWnd, $ID, $InputDefText, ByRef $DefaultInputData, ByRef $Mark)
If $Mark = 0 And _IsFocused($hWnd, $ID) And $DefaultInputData = $InputDefText Then
$Mark = 1
GUICtrlSetData($ID, "")
GUICtrlSetColor($ID, 0x000000)
$DefaultInputData = ""
ElseIf $Mark = 1 And Not _IsFocused($hWnd, $ID) And $DefaultInputData = "" And GUICtrlRead($ID) = "" Then
$Mark = 0
$DefaultInputData = $InputDefText
GUICtrlSetData($ID, $DefaultInputData)
GUICtrlSetColor($ID, $NONEAACTIVECOLOR)
EndIf
EndFunc ;==>_CheckInput
Func _IsFocused($hWnd, $nCID)
Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd))
EndFunc ;==>_IsFocused
Func _GetInternetIP()
Local $ip
$ip = InetRead("http://www.aamailsoft.com/getip.php", 1)
$ip = BinaryToString($ip)
If StringStripWS($ip, 8) <> "" Then
Return $ip
Else
Return "0.0.0.0"
EndIf
EndFunc ;==>_GetInternetIP