| View previous topic :: View next topic |
| Author |
Message |
Bytales
Joined: 06 Sep 2008 Posts: 84
|
Posted: Mon Sep 22, 2008 1:42 pm Post subject: Executing commands in a given time interval |
|
|
How can i execute a certain command if the time is say, between 14:35 and 14:55 ?
If time is betwen 14:35 and 14:55 (taken from windows or from other place, i don't know) ... >
Click there. |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Sep 22, 2008 2:11 pm Post subject: Re: Executing commands in a given time interval |
|
|
| Bytales wrote: | How can i execute a certain command if the time is say, between 14:35 and 14:55 ?
If time is betwen 14:35 and 14:55 (taken from windows or from other place, i don't know) ... >
Click there. |
Something like this (untested)
| Code: | alreadyRan = 0
startTime = 1435
endTime = 1455
if (A_Now > A_Year A_Mon A_MDay startTime) && (A_Now < A_Year A_Mon A_MDay stopTime) && !alreadyRan {
alreadyRan = 1
; Run command
} |
|
|
| Back to top |
|
 |
Bytales
Joined: 06 Sep 2008 Posts: 84
|
Posted: Mon Sep 22, 2008 3:29 pm Post subject: |
|
|
, what is this ?
and what is this
I don't understand that If at all, i do understand that the "run command" is between {}
but what are those:
| Code: | | (A_Now > A_Year A_Mon A_MDay startTime) && (A_Now < A_Year A_Mon A_MDay stopTime) && !alreadyRan |
|
|
| Back to top |
|
 |
Guest
|
Posted: Tue Sep 23, 2008 11:38 am Post subject: |
|
|
| Bytales wrote: |
but what are those:
| Code: | | (A_Now > A_Year A_Mon A_MDay startTime) && (A_Now < A_Year A_Mon A_MDay stopTime) && !alreadyRan |
|
"A_xxx" are AHK built-in variables. They are listed in the help file on this page
Here is the basic idea:
| Code: | ; get time window start/end in standard format
startTime = 1435 ; your window start time HHSS
endTime = 1455 ; your window end time HHSS
sTime := A_Year A_Mon A_MDay startTime 00 ; set start time in YYYYMMDD24HHMMSS format
eTime := A_Year A_Mon A_MDay endTime 00 ; set end time in YYYYMMDD24HHMMSS format
;
; your code here
loop, { ; loop until we are in time window
nTime := A_Now ; get current time in YYYYMMDD24HHMMSS format
if (nTime > sTime) && (nTime < eTime) {
break
}
sleep, 0.250 ; check current time every .25 seconds
}
; Run, YOUR_COMMAND
|
This is only one way to do this. Depending on your application you may want to use SetTimer to periodically check the current time, but it all depends on the exact need, |
|
| Back to top |
|
 |
Albireo
Joined: 01 Feb 2006 Posts: 240
|
Posted: Tue Sep 23, 2008 1:28 pm Post subject: |
|
|
Maybe You can use:
| Code: |
SetTimer, Label [, Period|On|Off, Priority] |
(86400000ms/24-hour period)
(But I think the previous example is better) |
|
| Back to top |
|
 |
|