找回密码
 加入
搜索
查看: 2300|回复: 2

[效率算法] 求教关于时间比较的问题[已解决]

[复制链接]
发表于 2012-1-9 14:46:14 | 显示全部楼层 |阅读模式
本帖最后由 tsys 于 2012-1-9 15:16 编辑

引用自A版的回复 http://www.autoitx.com/forum.php ... amp;page=1#pid90646,顺便将A版曾经发的代码贴出来:

问题是,如果将时间1 设置为:2330,时间2 设置为0830,那么一下代码在23:30分到早上8:00将只会运行 case else语句,请教如何解决。
#NoTrayIcon
#AutoIt3Wrapper_Icon=e:\autoit3\Aut2Exe\Icons\GoLive.ico
#AutoIt3Wrapper_Compression=4

If Not FileExists(@ScriptDir & "\set.ini") Then
        $sj = '时间1=0830' & @LF & '网关1=192.168.0.253' & @LF & '时间2=2030' & @LF & '网关2=192.168.0.1'
        IniWriteSection(@ScriptDir & '\set.ini', '配置', $sj)
EndIf

$time1 = IniRead(@ScriptDir & "\set.ini", "配置", "时间1", "")
$time2 = IniRead(@ScriptDir & "\set.ini", "配置", "时间2", "")
$GateWay_1 = IniRead(@ScriptDir & "\set.ini", "配置", "网关1", "")
$GateWay_2 = IniRead(@ScriptDir & "\set.ini", "配置", "网关2", "")

If $time1 = "" Or $time2 = "" Or $GateWay_1 = "" Or $GateWay_2 = "" Then _;如果无法从INI文件中获取全部数据  就给出提示
                Exit (MsgBox(0, "友情提示", "请先配置好 set.ini 文件 "))
If StringLen($time1 & $time2) <> 8 Then Exit (MsgBox(0, "友情提示", "时间格式不对,请使用4位数(且不带“:”) "))

Dim $WAY, $zx = 0
While 1
        Switch @HOUR & @MIN
                Case $time1 To $time2
                        If $WAY = 2 Or $zx = 0 Then
                                $WAY = 1
                                $zx = 1
                                GateWAY($GateWay_1)
                        EndIf
                Case Else
                        If $WAY = 1 Or $zx = 0 Then
                                $WAY = 2
                                $zx = 1
                                GateWAY($GateWay_2)
                        EndIf
        EndSwitch
        Sleep(2000)
WEnd

Func GateWAY($GateWay)
        Dim $array[1]
        $array[0] = $GateWay
        $strComputer = "."
        $objWMIService = ObjGet("winmgmts:\" & $strComputer & "\root\cimv2")
        $colNetAdapters = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
        If IsObj($colNetAdapters) Then
                For $objNetAdapter In $colNetAdapters
                        $objNetAdapter.SetGateways($array)
                Next
        EndIf
EndFunc   ;==>GateWAY
发表于 2012-8-21 14:40:34 | 显示全部楼层
路过,再路过
发表于 2012-10-21 17:34:39 | 显示全部楼层
不错的东西,感谢哈
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-29 21:22 , Processed in 0.084005 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表