AutoHotkey Community

It is currently May 25th, 2012, 8:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: October 19th, 2004, 6:50 pm 
Offline

Joined: July 30th, 2004, 11:30 pm
Posts: 74
Location: Deutschland (sorry for my english)
Hi Chris,

i searched the AHK help for an simple cron syntax.
Is there any?



Like:
AHKCron, <Minute> <Hour> <Day> <Month> <Day of Week> <Command line>

e.g.
AHKCron, 0 2 * 1-11 1-5 MsgBox, Coffee break


---
or e.g.

# start a backup every tuesday at midnight
AHKCron 0 0 * * 3 c:\tests\backup.bat



Is there such a simple syntax, i need a keyword to find this in the help.

Is this not, i wanna suggest this as new feature to use AHK as CRON.
I think about an "AHKCron.ahk" script file, containing those AHKCron commands.

THX
Stefan

_________________
Image Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2004, 7:42 pm 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
I'm OK with this proposition.

Perhaps it would be better to have :

AHKCron, Day, Month, Year, Hour, Minute, Seconds, Command line

and/or

AHKCron, +Minutes, Command line

where "+Minutes" stand for the number of minutes after the lauch of the ahk script or of the compiled exe script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2004, 8:15 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
That's on the to-do list as "Add scheduling by extending SetTimer, e.g. daily at a certain time, etc."

I have raised its priority and made a note of your ideas for when the time comes. Thanks.

In the meantime, you could use the built-in date-time math along with SetTimer to schedule something:
Code:
#persistent

TargetTime = 1400  ; run at 2pm, which is 1400.

StringLeft, TargetDateTime, A_Now, 8  ; Put just YYYYMMDD into the variable.
TargetDateTime = %TargetDateTime%%TargetTime%
TimeUntilTarget = %TargetDateTime%
TimeUntilTarget -= %A_Now%, seconds
if TimeUntilTarget < 0
{
     MsgBox The target time is already past!
     ExitApp
}
TimeUntilTarget *= 1000 ; Convert to milliseconds.
SetTimer, Timer1, %TimeUntilTarget%
return

Timer1:
SetTimer, Timer1, off  ; i.e. perform this subroutine only once.
; In case you want to be warned before it happens, in case it changes the
; active window or otherwise disrupts what the user is working on:
SplashTexton,,, It's about to happen.
Sleep, 3000
SplashTextOff
; And here perform whatever action you wanted scheduled:
; ...
return


Last edited by Chris on June 28th, 2005, 9:14 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2004, 8:38 pm 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
Very interesting code.
I'll keep waiting for a Cron command in AHK in the future.
Thanks Chris.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2004, 10:49 pm 
Offline

Joined: July 30th, 2004, 11:30 pm
Posts: 74
Location: Deutschland (sorry for my english)
Thanks for the answer.
Thanks for raised its priority too.


-----------------------------------------------.
Nemroth wrotes:
> Perhaps it would be better to have :
> AHKCron, Day, Month, Year, Hour, Minute, Seconds, Command line

No, i suggest highly to use the well famliliar and well testet UNIX syntax of cron.
AHKCron <Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week> <command>

* * * * *
| | | | |
| | | | |
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)

<command> could be an *.exe, *.com, *.bat, *cmd, *.vbs, *.ahk ... ,
or directly an AHK command or an AHK variable who will be found
as a part of a bigger script at the end of the AHKCron.ahk file.

Click here for syntax and examples
If you need more details, let me here pls!!!

-----------------------------------------------

Further more i suggest additional commands:

1) The char +, who means execute <command> 'n' minutes or seconds
or days after windows start, depending on the position of the '+' in
command line. (THX Nemroth for this very nice idea)

2) a sixt row * for the year (like nnCron)

3) a sevent row for this following chars:
   char ?, who means execute <command> during windows start.
    char #, who means execute <command> on windows shutdown (not on cancling the script).


-----------------------------------------------

> In the meantime,
Thanks for pointing me to this script.

_________________
Image Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2004, 11:59 pm 
Offline

Joined: July 2nd, 2004, 11:53 pm
Posts: 207
Quote:
Nemroth wrotes:
> Perhaps it would be better to have :
> AHKCron, Day, Month, Year, Hour, Minute, Seconds, Command line

No, i suggest highly to use the well famliliar and well testet UNIX syntax of cron.


I think nemroth's idea is probably the most appropriate. You have to consider the fact that AHK is all about simplicity and Nemroth's is certainly simpler and more natural. Also, I'm not sure how many of AHK's users would be familiar with UNIXen at all, and of those, how many of them actually know and use cron.

That being said, scheduling support would certainly be good.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 26th, 2004, 12:18 am 
Offline

Joined: August 23rd, 2004, 10:06 pm
Posts: 276
Location: East Bay, California USA
I am useing the built in Windows Scheduler myself. I can get it to launch complied AHK scripts when I need them to. Built in function would be nice, but in essence not very necessary for most users applications.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2005, 10:46 pm 
maybe you should think about introducing a bit more than just cron.
I am familiar with a shareware called "Macro Angel" which has good scheduling features (but some of the macro stuff sucks) - when you worked with that you know there is more to it than just a cron-command:
for example what should happen to the script when it failed - should it be rescheduled for next week, or disabled?

Also the scheduler should log when the script was execute in the past (plus results?). for example: a script that is due every monday and you turn on your computer and it is tuesday and the day before you had a holiday. There should be a feature saying: test if the script is/was due. if it is overdue:
a.) run it right away and reschedule it for next monday (tuesday?)
b.) ask what to do
c.) don't bother just wait for next monday


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2005, 11:44 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Thanks for the ideas. I've made a note to review them again when the time comes to work on this feature.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: my two cents worth
PostPosted: February 3rd, 2005, 3:42 am 
The time should be in the already establisted format used by other commands...

The elements of the YYYYMMDDHH24MISS format are:

YYYY The 4-digit year
MM The 2-digit month (01-12)
DD The 2-digit day of the month (01-31)
HH24 The 2-digit hour in 24-hour format (00-23) e.g. 09 is 9am, 21 is 9pm
MI The 2-digit minutes (00-59)
SS The 2-digit seconds (00-59)

If only a partial string is given for YYYYMMDDHH24MISS (e.g. 200403), any remaining element that has been omitted will be supplied with the following default values:

MM: Month 01
DD: Day 01
HH24: Hour 00
MI: Minute 00
SS: Second 00

The built-in variable A_Now contains the current local time in the above format.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2007, 12:45 pm 
Offline

Joined: July 30th, 2004, 11:30 pm
Posts: 74
Location: Deutschland (sorry for my english)
Hi Chris,
are there any news about an intern cron functionality?
This would be quit simpler then Timer / Sleep / IFs

Code:
#SingleInstance force
;every two working hours on Mo-Fr

CRON * 10,12,14,16 * * 1-5
(
MsgBox What have you done till now?
Run worksheet.xls
some AHK code here
)

Return



Reminder:
> Chris Posted: Tue Oct 19, 2004 9:15 pm
> That's on the to-do list as "Add scheduling by extending SetTimer,
> e.g. daily at a certain time, etc."



Thanks

_________________
Image Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 27th, 2007, 11:46 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Yes, it's still planned. I consider scheduling to be a pretty big benefit that would be used by quite a few people.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2007, 7:32 am 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
FYI
I am currently working on a script offering cron capabilities.
It will be packeted in two parts: a library and a standalone interface using the library.
I hope the library will be ready in the end of this week (ultimo august 07 ;-)). The interface some weeks later.

EDIT:
The first beta version is out: http://www.autohotkey.com/forum/viewtopic.php?p=143772#143772

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2010, 2:34 am 
Offline

Joined: February 16th, 2010, 4:01 am
Posts: 60
Chris wrote:
That's on the to-do list as "Add scheduling by extending SetTimer, e.g. daily at a certain time, etc."

I have raised its priority and made a note of your ideas for when the time comes. Thanks.

In the meantime, you could use the built-in date-time math along with SetTimer to schedule something:
Code:
#persistent

TargetTime = 1400  ; run at 2pm, which is 1400.

StringLeft, TargetDateTime, A_Now, 8  ; Put just YYYYMMDD into the variable.
TargetDateTime = %TargetDateTime%%TargetTime%
TimeUntilTarget = %TargetDateTime%
TimeUntilTarget -= %A_Now%, seconds
if TimeUntilTarget < 0
{
     MsgBox The target time is already past!
     ExitApp
}
TimeUntilTarget *= 1000 ; Convert to milliseconds.
SetTimer, Timer1, %TimeUntilTarget%
return

Timer1:
SetTimer, Timer1, off  ; i.e. perform this subroutine only once.
; In case you want to be warned before it happens, in case it changes the
; active window or otherwise disrupts what the user is working on:
SplashTexton,,, It's about to happen.
Sleep, 3000
SplashTextOff
; And here perform whatever action you wanted scheduled:
; ...
return


I like this code but I'm interested in changing the red line. Instead of exiting, can this be made to set the timer to go off at the specified time on the following day? ie, add 24 hours to it?


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 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