I've a python program which has datetimes.
I'll save those to a file.
I want an AHK script to read that file and do something at those times (give or take 1-min).
1) What format would be best to save the datetimes in so that AHK can read it into a usable data structure?
2) In AHK, how would I read it in?
3) How do I do datetime comparison with current system time?
Read datetimes from file and perform action when each. Topic is solved
Re: Read datetimes from file and perform action when each.
YYYYMMDDHH24MISS1) What format would be best to save the datetimes in so that AHK can read it into a usable data structure?
FileRead2) In AHK, how would I read it in?
EnvSub3) How do I do datetime comparison with current system time?
Re: Read datetimes from file and perform action when each. Topic is solved
Thanks m8.
Code: Select all
SetTimer, checkIfScheduledRightNow, 60000
checkIfScheduledRightNow() {
scheduleFile := "schedule.txt"
if !FileExist(scheduleFile) {
MsgBox, 16, Error, Schedule file not found!
return
}
FileRead, fileContents, %scheduleFile%
Loop, Parse, fileContents, `n {
; Skip empty lines
if (A_LoopField = "")
continue
; Get current timestamp
FormatTime, currentTime,, yyyyMMddHHmm
; get this schedule entry
dateTimeAndDiff := A_LoopField
MsgBox, Date Time: %dateTimeAndDiff%
; get the difference between the two
EnvSub, dateTimeAndDiff, %A_Now%, minutes
MsgBox, Difference in mins: %dateTimeAndDiff%
; check if it's 1-min before the hour or within the hour
if (-59 <= dateTimeAndDiff and dateTimeAndDiff <= 1) {
FormatTime, formattedTime, %A_LoopField%, h:mm tt
ToolTipTimer("You're scheduled right now at " formattedTime)
return
}
}
}
Who is online
Users browsing this forum: Google [Bot] and 110 guests