请教:循环后时间出错,怎么解决?(在线等啊,急!)
#include <GUIConstants.au3>#include <Date.au3>
Global $time1end, $time2end
GUICreate("延迟时间", 300, 250)
GUICtrlCreateGroup("", 20, 20, 260, 90)
$Checkbox1 = GUICtrlCreateCheckbox("第一次", 15, 60, 65, 20)
GUISetState(@SW_SHOW)
GUICtrlCreateLabel("时间延迟:", 65, 45)
$wait1 = GUICtrlCreateInput("10", 150, 40, 38, 20)
GUICtrlCreateLabel("秒", 195, 45)
$Label1 = GUICtrlCreateLabel('核弹爆炸倒计时:____秒', 65, 80, 200, 20)
GUICtrlCreateGroup("", 20, 120, 260, 90)
$Checkbox2 = GUICtrlCreateCheckbox("第二次", 15, 160, 65, 20)
GUICtrlCreateLabel("时间延迟:", 65, 145)
$wait2 = GUICtrlCreateInput("15", 150, 140, 38, 20)
GUICtrlCreateLabel("秒", 195, 145)
$Label2 = GUICtrlCreateLabel('核弹爆炸倒计时:____秒', 65, 180, 200, 20)
$okbutton = GUICtrlCreateButton("OK", 120, 220, 60)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $okbutton
If GUICtrlRead($okbutton) = "OK" Then
If GUICtrlRead($Checkbox1) = $gui_checked Then
$time1end = _DateAdd('s', GUICtrlRead($wait1), _NowCalc())
EndIf
If GUICtrlRead($Checkbox2) = $gui_checked Then
$time2end = _DateAdd('s', GUICtrlRead($wait2), _NowCalc())
EndIf
EndIf
AdlibEnable("daojishi")
EndSwitch
WEnd
Func Daojishi()
If GUICtrlRead($Checkbox1) = $gui_checked Then
$t1 = _DateDiff("s", _NowCalc(), $time1end)
If $t1 >= 0 Then
GUICtrlSetData($Label1, '核弹爆炸倒计时:' & $t1 & '秒')
Else
TrayTip('Info', '第一次倒计时时间到!', 5)
GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
$year1=2007
$month1=8
$date1=9
$hour1=5
$minute1=6
$second1=7
run("cmd")
sleep(500)
send("date "&$year1&"-"&$month1&"-"&$date1&"{enter}")
sleep(500)
send("time "&$hour1&":"&$minute1&":"&$second1&"{enter}")
sleep(500)
send("exit"&"{enter}")
EndIf
EndIf
If GUICtrlRead($Checkbox2) = $gui_checked Then
$t2 = _DateDiff("s", _NowCalc(), $time2end)
If $t2 >= 0 Then
GUICtrlSetData($Label2, '核弹爆炸倒计时:' & $t2 & '秒')
Else
TrayTip('Info', '第二次倒计时时间到!', 5)
GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
$year2=2008
$month2=4
$date2=12
$hour2=6
$minute2=2
$second2=7
run("cmd")
sleep(500)
send("date "&$year2&"-"&$month2&"-"&$date2&"{enter}")
sleep(500)
send("time "&$hour2&":"&$minute2&":"&$second2&"{enter}")
sleep(500)
send("exit"&"{enter}")
EndIf
EndIf
If GUICtrlRead($Checkbox1) = $gui_unchecked And GUICtrlRead($Checkbox2) = $gui_unchecked Then AdlibDisable()
EndFunc
上面的,如选两个倒计时,第一个倒计时结束后,第二个倒时间会改变数值,请问能不能等第一个倒计时结束了再开始执行第二个倒计时?
还有下面这段改时间的为什么在英文版2000里执行不对?
$year=2005
$month=6
$date=7
$hour=8
$minute=9
$second=10
If$hour>=8 Then
$hour=$hour-8
ElseIf $hour=7 Then
$hour=30-$hour
$date=$date-1
ElseIf $hour=6 Then
$hour=28-$hour
$date=$date-1
ElseIf $hour=5 Then
$hour=26-$hour
$date=$date-1
ElseIf $hour=4 Then
$hour=24-$hour
$date=$date-1
ElseIf $hour=3 Then
$hour=22-$hour
$date=$date-1
ElseIf $hour=2 Then
$hour=20-$hour
$date=$date-1
ElseIf $hour=1 Then
$hour=18-$hour
$date=$date-1
ElseIf $hour=0 Then
$hour=16-$hour
$date=$date-1
EndIf
$Systime= DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
$blah = dllopen("kernel32.dll")
DllStructSetData($Systime,1,$year)
DllStructSetData($Systime,2,$month)
DllStructSetData($Systime,4,$date)
DllStructSetData($Systime,5,$hour)
DllStructSetData($Systime,6,$minute)
DllStructSetData($Systime,7,$second)
$arg = DLLCALL($blah,"long","SetSystemTime","ptr",DllStructGetPtr($Systime))
dllclose($blah) 顶下
怎么先进行第一个倒计时.结束后再开始第二个倒计时?
#include <GUIConstants.au3>
#include <Date.au3>
Global $time1end, $time2end, $t1
GUICreate("延迟时间", 300, 250)
GUICtrlCreateGroup("", 20, 20, 260, 90)
$Checkbox1 = GUICtrlCreateCheckbox("第一次", 15, 60, 65, 20)
GUISetState(@SW_SHOW)
GUICtrlCreateLabel("时间延迟:", 65, 45)
$wait1 = GUICtrlCreateInput("10", 150, 40, 38, 20)
GUICtrlCreateLabel("秒", 195, 45)
$Label1 = GUICtrlCreateLabel('核弹爆炸倒计时:____秒', 65, 80, 200, 20)
GUICtrlCreateGroup("", 20, 120, 260, 90)
$Checkbox2 = GUICtrlCreateCheckbox("第二次", 15, 160, 65, 20)
GUICtrlCreateLabel("时间延迟:", 65, 145)
$wait2 = GUICtrlCreateInput("15", 150, 140, 38, 20)
GUICtrlCreateLabel("秒", 195, 145)
$Label2 = GUICtrlCreateLabel('核弹爆炸倒计时:____秒', 65, 180, 200, 20)
$okbutton = GUICtrlCreateButton("OK", 120, 220, 60)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $okbutton
$time1end = _DateAdd('s', GUICtrlRead($wait1), _NowCalc())
AdlibEnable("daojishi")
EndSwitch
If GUICtrlRead($Checkbox2) = $gui_checked And $t1 = 0 Then
$time2end = _DateAdd('s', GUICtrlRead($wait2), _NowCalc())
EndIf
WEnd
Func Daojishi()
If GUICtrlRead($Checkbox1) = $gui_checked Then
$t1 = _DateDiff("s", _NowCalc(), $time1end)
If $t1 >= 0 Then
GUICtrlSetData($Label1, '核弹爆炸倒计时:' & $t1 & '秒')
Else
TrayTip('Info', '第一次倒计时时间到!', 5)
GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
$year1 = 2007
$month1 = 8
$date1 = 9
$hour1 = 5
$minute1 = 6
$second1 = 7
Run("cmd")
Sleep(500)
Send("date " & $year1 & "-" & $month1 & "-" & $date1 & "{enter}")
Sleep(500)
Send("time " & $hour1 & ":" & $minute1 & ":" & $second1 & "{enter}")
Sleep(500)
Send("exit" & "{enter}")
EndIf
EndIf
If GUICtrlRead($Checkbox2) = $gui_checked And $t1 <= 0 Then
$t2 = _DateDiff("s", _NowCalc(), $time2end)
If $t2 >= 0 Then
GUICtrlSetData($Label2, '核弹爆炸倒计时:' & $t2 & '秒')
Else
TrayTip('Info', '第二次倒计时时间到!', 5)
GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
$year2 = 2008
$month2 = 4
$date2 = 12
$hour2 = 6
$minute2 = 2
$second2 = 7
Run("cmd")
Sleep(500)
Send("date " & $year2 & "-" & $month2 & "-" & $date2 & "{enter}")
Sleep(500)
Send("time " & $hour2 & ":" & $minute2 & ":" & $second2 & "{enter}")
Sleep(500)
Send("exit" & "{enter}")
EndIf
EndIf
If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED And GUICtrlRead($Checkbox2) = $GUI_UNCHECKED Then AdlibDisable()
EndFunc ;==>Daojishi
这段在2000里为什么不能用?
$year=2005$month=6
$date=7
$hour=8
$minute=9
$second=10
If$hour>=8 Then
$hour=$hour-8
ElseIf $hour=7 Then
$hour=30-$hour
$date=$date-1
ElseIf $hour=6 Then
$hour=28-$hour
$date=$date-1
ElseIf $hour=5 Then
$hour=26-$hour
$date=$date-1
ElseIf $hour=4 Then
$hour=24-$hour
$date=$date-1
ElseIf $hour=3 Then
$hour=22-$hour
$date=$date-1
ElseIf $hour=2 Then
$hour=20-$hour
$date=$date-1
ElseIf $hour=1 Then
$hour=18-$hour
$date=$date-1
ElseIf $hour=0 Then
$hour=16-$hour
$date=$date-1
EndIf
$Systime= DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
$blah = dllopen("kernel32.dll")
DllStructSetData($Systime,1,$year)
DllStructSetData($Systime,2,$month)
DllStructSetData($Systime,4,$date)
DllStructSetData($Systime,5,$hour)
DllStructSetData($Systime,6,$minute)
DllStructSetData($Systime,7,$second)
$arg = DLLCALL($blah,"long","SetSystemTime","ptr",DllStructGetPtr($Systime))
dllclose($blah) 窗口不在当前状态能发送文字吗?
比如自动打开"CMD"后,我鼠标操作了其他窗口,但是CMD窗口我还是要按照设定修改时间,liongodmien大侠给的办法,不能动鼠标,一动,不在当前状态,就不能往下执行了 用CONTROLSEND()
[ 本帖最后由 liongodmien 于 2008-10-30 16:40 编辑 ]
谢谢!
哪里有各种循环详细点的教程吗?最好每句都有解释.修改电脑系统时间除了用"CMD",还有什么?能给例子吗? #include <Date.au3>
_SetTime(20,15) ; Set time to 20:15
_SetTime(20,15,30) ; Set time to 20:15:30
谢谢楼上
如窗口信息工具没法获取软件窗口信息怎么办?我有个应用软件,一开窗口信息工具一点上就出错给关了.还有下面的
run("CMD")
sleep(1000)
ControlSend("C:\WINDOWS\system32\cmd.exe - date","","","exit")
就没法用,除非前面C:\WINDOWS\system32\cmd.exe - date不写,那和send() 没什么区别了啊 run("cmd")
Sleep(1000)
ControlSend("C:\WINDOWS\system32\cmd","","","exit") 试试吧。:face (31):
[ 本帖最后由 gs008970 于 2008-11-4 00:09 编辑 ]
谢谢!
GUICtrlCreateDate( )和_Setdate()怎么联用?或者GUICtrlCreateDate( ) 和其他联用修改系统日期?
页:
[1]