AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Executing commands in a given time interval

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Bytales



Joined: 06 Sep 2008
Posts: 84

PostPosted: Mon Sep 22, 2008 1:42 pm    Post subject: Executing commands in a given time interval Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Mon Sep 22, 2008 2:11 pm    Post subject: Re: Executing commands in a given time interval Reply with quote

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

PostPosted: Mon Sep 22, 2008 3:29 pm    Post subject: Reply with quote

Code:
alreadyRan = 0
, 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
View user's profile Send private message
Guest






PostPosted: Tue Sep 23, 2008 11:38 am    Post subject: Reply with quote

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

PostPosted: Tue Sep 23, 2008 1:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group