AutoHotkey Community

It is currently May 26th, 2012, 9:28 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: September 22nd, 2008, 2:42 pm 
Offline

Joined: September 6th, 2008, 3:11 pm
Posts: 84
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.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 22nd, 2008, 3:11 pm 
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
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2008, 4:29 pm 
Offline

Joined: September 6th, 2008, 3:11 pm
Posts: 84
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2008, 12:38 pm 
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,


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2008, 2:28 pm 
Offline

Joined: February 1st, 2006, 4:37 pm
Posts: 365
Maybe You can use:
Code:
SetTimer, Label [, Period|On|Off, Priority]

(86400000ms/24-hour period)

(But I think the previous example is better)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: iBob35555VR, tomoe_uehara and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group