找回密码
 加入
搜索
查看: 3505|回复: 4

时间算法问题???

[复制链接]
发表于 2008-5-7 00:58:30 | 显示全部楼层 |阅读模式
Global $Sec, $Min, $Hour, $Time
$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC)
$EndTicks = $StartTicks + $Label2* 60 * 1000
_TicksToTime($EndTicks,$Hour,$Min,$Sec)
MsgBox(262144,'' , '关机时间为:' &  $Hour & ":" & $Min & ":" & $Sec)

每次我在带入$Label2这个变量值时都  和我直接改$Label2   的时间不一样啊


比喻 我的系统时间是1:00   我在$Label2  这里带入的是1  想在1:01这个时间关机  提示说的是1:10啊
(意思就是在我所指定的时间上他怎么退后了 10分钟啊 )

不过要是我自己手工  把那个$Label2改为1  的话它又是正确的   
这是什么搞的啊

[ 本帖最后由 男孩 于 2008-5-8 12:56 编辑 ]
发表于 2008-5-7 09:13:29 | 显示全部楼层
这样不是更加容易理解:

#include <Date.au3>
Global $Sec, $Min, $Hour, $Time
$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC)
$EndTicks = $StartTicks + _TimeToTicks(0,1,0);延时1分,可使用变量
;$EndTicks = $StartTicks + _TimeToTicks(0,8,8);延时8分8秒
_TicksToTime($EndTicks,$Hour,$Min,$Sec)
MsgBox(262144,'' , '关机时间为 ' &  StringFormat("%02i:%02i:%02i", $Hour, $Min, $Sec))
 楼主| 发表于 2008-5-7 13:23:13 | 显示全部楼层
好像 还是有点问题啊    定义的 和显示的 时间不一样啊

源码  
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <date.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("定时器", 265, 127, 230, 160)
$Pic1 = GUICtrlCreatePic("D:\CPU的文档\男孩.JPG", 0, 0, 131, 126, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Group1 = GUICtrlCreateGroup("编辑区", 135, 0, 126, 126)
$Button1 = GUICtrlCreateButton("确定", 155, 100, 86, 21, 0)
$radio1 = GUICtrlCreateRadio("关机", 145, 20, 43, 17)
$radio2 = GUICtrlCreateRadio("待机", 205, 20, 51, 16)
GUICtrlSetState($radio1, $GUI_CHECKED)
GUICtrlCreateInput("", 140, 55, 31, 21)
$Label1 = GUICtrlCreateLabel("时", 180, 55, 16, 17)
GUICtrlCreateInput("", 205, 55, 31, 21)
$Label2 = GUICtrlCreateLabel("分", 240, 55, 16, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ### Form=
Dim $Label1 , $Label2
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                       
                        times()
                        Exit
        EndSwitch
WEnd
Func times()
        Global $Sec, $Min, $Hour, $Time
$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC)
$EndTicks = $StartTicks + _TimeToTicks($Label1,$Label2,0);延时1分,可使用变量
;$EndTicks = $StartTicks + _TimeToTicks(0,8,8);延时8分8秒
_TicksToTime($EndTicks,$Hour,$Min,$Sec)
MsgBox(262144,'' , '关机时间为 ' &  StringFormat("%02i:%02i:%02i", $Hour, $Min, $Sec))
EndFunc   ;==>times
发表于 2008-5-7 21:02:15 | 显示全部楼层

回复 3# 男孩 的帖子

楼主还要学习一下基本功.
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <date.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("定时器", 265, 127, 230, 160)
$Pic1 = GUICtrlCreatePic("D:\CPU的文档\男孩.JPG", 0, 0, 131, 126, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Group1 = GUICtrlCreateGroup("编辑区", 135, 0, 126, 126)
$Button1 = GUICtrlCreateButton("确定", 155, 100, 86, 21, 0)
$radio1 = GUICtrlCreateRadio("关机", 145, 20, 43, 17)
$radio2 = GUICtrlCreateRadio("待机", 205, 20, 51, 16)
GUICtrlSetState($radio1, $GUI_CHECKED)
$input1=GUICtrlCreateInput("", 140, 55, 31, 21)
$Label1 = GUICtrlCreateLabel("时", 180, 55, 16, 17)
$input2=GUICtrlCreateInput("", 205, 55, 31, 21)
$Label2 = GUICtrlCreateLabel("分", 240, 55, 16, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ### Form=

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        
                        times()
                  
        EndSwitch
WEnd
Func times()
     Local $Sec, $Min, $Hour, $Time
$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC)
$EndTicks = $StartTicks + _TimeToTicks(Number(GUICtrlRead($input1)),Number(GUICtrlRead($input2)),0);延时1分,可使用变量
;$EndTicks = $StartTicks + _TimeToTicks(0,8,8);延时8分8秒
_TicksToTime($EndTicks,$Hour,$Min,$Sec)
MsgBox(262144,'' , '关机时间为 ' &  StringFormat("%02i:%02i:%02i", $Hour, $Min, $Sec))
EndFunc   ;==>times
 楼主| 发表于 2008-5-8 13:00:43 | 显示全部楼层

谢谢   我会努力的
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-9 04:17 , Processed in 0.070162 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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