How to run commands at a certain time without using loop?
#1
Posted 25 May 2008 - 12:49 PM
[ Moderator!: [b/b] tag removed ]
#2
Posted 25 May 2008 - 05:37 PM
Meaning that currently we do not have that feature. I have a couple of features that I simply use SetTimer checking the time to decide whether or not they activate, which as far as I know is the only current way.Add scheduling by extending SetTimer, e.g. daily at a certain time, etc.
#3
Z Gecko
Posted 25 May 2008 - 06:25 PM
you could try out the task-scheduler of windows.
More Info:
http://www.autohotke...t=schedule task
http://www.autohotke...t=schedule task
#4
Guests
Posted 26 May 2008 - 05:20 AM
Time = 2:00 ; time - HH24:MM
T := 86400 - (SubStr(A_Now,-5,2)*60 + SubStr(A_Now,-3,2))*60 + SubStr(A_Now,-1,2) + (RegExReplace(Time,"^[0-9]{1,2}:([0-9]{2})$","$1") + RegExReplace(Time,"^([0-9]{1,2}):[0-9]{2}$","$1")*60)*60
SetTimer, DoSomething, % T*1000 ; DoSomething at "Time"
#5
Posted 26 May 2008 - 05:58 PM
Could it can pass the first time to run?Unfortunately, under the features pending implementation:
Meaning that currently we do not have that feature. I have a couple of features that I simply use SetTimer checking the time to decide whether or not they activate, which as far as I know is the only current way.Add scheduling by extending SetTimer, e.g. daily at a certain time, etc.
#6
Posted 26 May 2008 - 06:02 PM
Who are you body? That's exactly what I want and qqq so much!Something like this should work, as long as you start it before midnight on the day you want it to do something.
Time = 2:00 ; time - HH24:MM T := 86400 - (SubStr(A_Now,-5,2)*60 + SubStr(A_Now,-3,2))*60 + SubStr(A_Now,-1,2) + (RegExReplace(Time,"^[0-9]{1,2}:([0-9]{2})$","$1") + RegExReplace(Time,"^([0-9]{1,2}):[0-9]{2}$","$1")*60)*60 SetTimer, DoSomething, % T*1000 ; DoSomething at "Time"
#7
Posted 26 May 2008 - 06:10 PM
StringMid,MC,A_Now,11,2
StringMid,HC,A_Now,9,2
DL := (60-MC+(25-HC)*60)*60000
If (A_Hour > 1 And A_Hour < 7)
{
Shutdown 5
}
Sleep %DL%
Shutdown 5 Now I use such code and it works well.
#8
VOODOOS!L
Posted 20 September 2011 - 03:13 PM
; Time Registration
#Persistent
#SingleInstance,force
REGISTER_FUTURE:
TNowHour := SubStr(A_Now,-5,2)
TNowMin := SubStr(A_Now,-3,2)
TNowSec := SubStr(A_Now,-1,2)
TNowInSec := ((TNowHour*60 + TNowMin) * 60 + TNowSec)
TParamHour := RegExReplace(timeParam,"^([0-9]{1,2}):[0-9]{2}$","$1")
TParamMin := RegExReplace(timeParam,"^[0-9]{1,2}:([0-9]{2})$","$1")
TParamInSec := (TParamHour*60 + TParamMin) * 60
delayInSec := 0
If (TParamInSec > TNowInSec) {
;now : 9u00
;to run: 9u05
;delay = 5min = 9u05 - 9u00
delayInSec := TParamInSec - TNowInSec
} else {
; now : 9u05
; to run: 9u00
; delay = 24u - 5min = 86400 sec - (9u05 - 9u00)
delayInSec := 86400 - ( TNowInSec - TParamInSec)
}
SetTimer, REGISTER_NOW, % delayInSec*-1000 ; convert to millisec and make negative to denote only run once
TrayTip, Timer configured, Start in %delayInSec%sec at %TParamHour%:%TParamMin%
;MsgBox Timer configured in: %delayInSec% sec at %TParamHour%:%TParamMin%
return
DISABLE_FUTURE:
SetTimer, REGISTER_NOW, Off
return
REGISTER_NOW:
;add code to be executed at exact time you provided
return
#9
VOODOOS!L
Posted 20 September 2011 - 03:16 PM
timeParam should contain the exact time at witch the timer should be exectued, in format HH:MM
#10
Guests
Posted 03 October 2011 - 02:30 PM
But then with a time that is supposed to be 1 minute in the future, it says the alarm will go off in "218846 seconds" at "0604:0604". Same issue with "06.33:06.33".
#11
Guests
Posted 05 October 2011 - 03:35 AM
error := 19:45 ; Invalid - two numbers separated by : operator. okay := "19:45" ; Quoted string in an expression. okay = 19:45 ; Literal (non-expression) assignment.
#12
Guests
Posted 05 October 2011 - 09:16 AM




