 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
adamrgolf
Joined: 28 Dec 2006 Posts: 362
|
Posted: Wed Apr 11, 2007 11:38 am Post subject: Determine a "Next Run" day |
|
|
If I have an ini file as follows:
| Code: | [Details]
LastRan=Wed Apr 11th at 05:09
[Occurrence]
Friday=0
Saturday=1
Sunday=0
Monday=0
Tuesday=0
Wednesday=1
Thursday=0 |
and a script that checks if A_DDDD is equal to 1, if so then do something and update the "LastRan" value by iniwrite ... I want to include in my code the ability to pop up a message box to see when the "next run" day will be... so if this certain ini file was last ran Wednesday, the next run date will be Saturday, since Thursday and Friday are 0's... how would I do this? It would also be nice if this was not just day specific, but month specific also... so if the last ran day was for instance Wednesday of March, then the next run date would be today, Wednesday of April...
this seems to be to complicate for me to figure out, can anyone offer any ideas?
Thanks!!
Adam |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Apr 11, 2007 11:57 am Post subject: |
|
|
Why not check the help for Gui/Add/MonthCal ?
| Code: | Gui, Add, MonthCal, vMyCalendar gMyCalendar
Gui, Show
Return
MyCalendar:
FormatTime, Date, %MyCalendar%, WDay
If Date = 4 ; wednesday
MsgBox It's Wednesday
Return | Mix it with INIRead/-Write ... |
|
| Back to top |
|
 |
adamrgolf
Joined: 28 Dec 2006 Posts: 362
|
Posted: Thu Apr 12, 2007 6:46 am Post subject: |
|
|
| Hmm, is there no way to determine the next run day like I mentioned in the first post without using this monthcal thing? I dont think I want to use it |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Thu Apr 12, 2007 7:39 am Post subject: |
|
|
| Code: | FormatTime, LastRunDate, , LongDate
FormatTime, DayName, , dddd
INIRead, Day, My.ini, Occurrence, %DayName%
If Day = 1
{
MsgBox Today is the day!
INIWrite, %LastRunDate%, My.ini, Details, LastRan
} | Not tested. |
|
| Back to top |
|
 |
adamrgolf
Joined: 28 Dec 2006 Posts: 362
|
Posted: Fri Apr 13, 2007 11:56 am Post subject: |
|
|
BoBo, this would only work if I wanted to know if it is going to run today --
Does anyone have any idea how to do what my first post asks?
This baffles me, it is a bit to complicated for me to figure out.
if toady is friday, and my task will run, monday wednesday and friday, and it has already ran today, then when will it run next: the file that determines when a script runs is as follows
| Code: | [Details]
LastRan=Fri Apr 13th at 05:09
[Occurrence]
Monday: 1
Tuesday: 0
Wednesday: 1
Thursday: 0
Friday: 1
Saturday: 0
Sunday: 0 |
|
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Fri Apr 13, 2007 12:05 pm Post subject: |
|
|
FormatTime only works with the YYYYMMDDHH24MISS date format. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
bold
Joined: 20 Apr 2006 Posts: 15
|
Posted: Fri Apr 13, 2007 12:41 pm Post subject: |
|
|
Check out EnvAdd in the manual. You can do date calculations like this snippet (from the manual):
| Code: | var1 = ; Make it blank so that the below will use the current time instead.
var1 += 31, days
FormatTime, t, %var1%
MsgBox, %t% ; The answer will be the date 31 days from now. |
You should be able to find out the difference in days between the current weekday and the next runday with a loop and the help of A_WDay.
Then you add the number of days to the current day as in the above snippet, format the time and that's it. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|