AutoIt: Проверка наличието на интернет
Публикувано: 09.09.13, 01:13:31 | Автор: ArMeN | Видяна: 1178 | Редактирано: 19.07.16, 21:10:41
$var = Ping("www.google.com",250)
If $var Then
Msgbox(0,"Status","Online")
Else
Msgbox(0,"Status","offline")
EndIfPingG()
Func PingG()
Sleep(1000)
$var = Ping("www.google.com",1000)
If $var Then
Msgbox(0,"Status","Online")
Else
PingG()
EndIf
EndFunc$connect = _GetNetworkConnect()
If $connect Then
MsgBox(64, "Connections", $connect)
Else
MsgBox(48, "Warning", "There is no connection")
EndIf
Func _GetNetworkConnect()
Local Const $NETWORK_ALIVE_LAN = 0x1 ;net card connection
Local Const $NETWORK_ALIVE_WAN = 0x2 ;RAS (internet) connection
Local Const $NETWORK_ALIVE_AOL = 0x4 ;AOL
Local $aRet, $iResult
$aRet = DllCall("sensapi.dll", "int", "IsNetworkAlive", "int*", 0)
If BitAND($aRet[1], $NETWORK_ALIVE_LAN) Then $iResult &= "LAN connected" & @LF
If BitAND($aRet[1], $NETWORK_ALIVE_WAN) Then $iResult &= "WAN connected" & @LF
If BitAND($aRet[1], $NETWORK_ALIVE_AOL) Then $iResult &= "AOL connected" & @LF
Return $iResult
EndFunc
Скрипта проверява 10 пъти наличието на интернетFor $X = 1 to 10
$result = Ping("www.google.com")
If @ERROR Then ContinueLoop
MsgBox(0,"","Ping successful")
Next
Проверка наличието на интернет през определено време;код...............
AdlibRegister('_CheckNet', 10)
;код...............
Func _CheckNet()
If Not Ping('www.autoit-script.ru') > 0 Then
Do
Sleep(100)
Until Ping('www.autoit-script.ru') > 0
EndIf
EndFunc
Източник
Няма коментари.