时间算法问题???
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 编辑 ] 这样不是更加容易理解:
#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)) 好像 还是有点问题啊 定义的 和显示的 时间不一样啊
源码
#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
回复 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 :face (35):
谢谢 我会努力的
页:
[1]