找回密码
 加入
搜索
查看: 5057|回复: 10

[AU3基础] 请问如何让程序在10分钟后运行?(已解决)

 火.. [复制链接]
发表于 2011-11-3 23:16:17 | 显示全部楼层 |阅读模式
本帖最后由 mtvtop 于 2011-11-4 11:08 编辑

我要怎么写程序才能让$Input1里的4:59分的时间实时倒数,当为00:00秒的时候运行程序?
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 446, 217, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 136, 40, 153, 21)
GUICtrlSetData($Input1 ,"9:59",1)
$Label1 = GUICtrlCreateLabel("开始运行时间倒数", 24, 40, 108, 17)
$Button1 = GUICtrlCreateButton("运行", 120, 88, 105, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                Case $Button1 
                                                MsgBox(0,"错误","时间到了" )


        EndSwitch
WEnd
发表于 2011-11-4 02:28:47 | 显示全部楼层
本帖最后由 gzh888666 于 2011-11-4 02:31 编辑

请问如何让程序在10分钟后运行?
sleep(100*1000)

想显示到gui控件中,循环规定时间内不断改写控件的值就可以了!
发表于 2011-11-4 08:21:58 | 显示全部楼层
楼上你那个是10分钟吗

sleep(10*60*1000)
发表于 2011-11-4 10:01:52 | 显示全部楼层
又学到新东西了.
发表于 2011-11-4 11:00:23 | 显示全部楼层
回复 2# gzh888666
哈哈 你这时间不对啊~drunk写的才是~!~
 楼主| 发表于 2011-11-4 11:08:03 | 显示全部楼层
谢谢大家,认真学了
发表于 2011-11-4 11:14:37 | 显示全部楼层
也不是很懂。刚学
发表于 2011-11-4 13:02:51 | 显示全部楼层
回复 2# gzh888666
其实这个问题的难点是倒计时显示,我认为的
发表于 2011-11-4 18:06:19 | 显示全部楼层
回复 8# xms77
倒计时显示

#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("Form1", 446, 217, 192, 124)
$Input1 = GUICtrlCreateInput("", 136, 40, 153, 21)
$Label1 = GUICtrlCreateLabel("开始运行时间倒数", 24, 40, 108, 17)
$Button1 = GUICtrlCreateButton("运行", 120, 88, 105, 41)
GUISetState(@SW_SHOW)
Global $Sec, $Min, $Hour, $Time,$iTicks ;定义变量
$StartTicks = _TimeToTicks(@HOUR, @MIN, @SEC) ;将当前时间转化为毫秒数
$EndTicks = $StartTicks + 5 * 60 * 1000 ;增加5分钟的毫秒数
#EndRegion ### END Koda GUI section ###
While 1
         _jishi()
         If $iTicks = 0 Then MsgBox(0, "错误", "时间到了")  ;为0 说明时间到了,执行操作
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0, "错误", "时间到了")
        EndSwitch
WEnd

Func _jishi() ;倒计时显示,虽然用SLEEP也可以,但是我觉得这样好像准点
        $nowTicks = _TimeToTicks(@HOUR, @MIN, @SEC) ;将当前时间转化为毫秒数
        $iTicks = $EndTicks - $nowTicks ;算差的毫秒数
        _TicksToTime($iTicks, $Hour, $Min, $Sec) ;转为时分秒
        $Time = StringFormat("%02i:%02i:%02i", $Hour, $Min, $Sec) ;格式
        GUICtrlSetData($Input1, $Time) ;显示
EndFunc   ;==>_jishi


发表于 2011-11-5 18:24:05 | 显示全部楼层
回复 9# 骗子
学习了,多谢啊!
发表于 2011-11-5 19:21:53 | 显示全部楼层
厉害,学习了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-1 09:38 , Processed in 0.079436 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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