Automation with AppleScript

Scripting

Timeframe is scriptable via AppleScript. To get an overview of supported commands, start the Script Editor app and drag Timeframe.app onto its dock icon.

Examples

export last x days of Timeframe data to XML
ExportXML url "/Users/[username]/Downloads/Timeframe/AllDays.xml" days 31

start/stop the timer of a task with ID
ToggleTimerOfTaskID "9DD6...865A"

list IDs of currently running tasks
runningTaskIDs

create a task with name
CreateTask name "t"

create a subtask of a task with and add a description
CreateTask name "t" parentTaskID "9DD6...865A" description "first task"

create a task and add a subtask to it
CreateTask name "parent"
set taskID to id of previousTask
CreateTask name "child" parentTaskID taskID

create a timing for a task with start time, end time, and note
CreateTiming taskID "47736…0627" startDate ((current date) - 3600) endDate (current date) note "text"

create a timing for a task using separate commands setting start time and end time CreateTiming taskID "47736…0627" startDate date ("13/01/2018 17:45")
if exists previousTiming then StopTiming timingID id of previousTiming endDate date ("13/01/2018 18:15") note “text”

fetch IDs of all timings of all tasks (not including archived tasks) and store them into previousTimingIDs
GetTimingIDs

fetch IDs of all timings starting between startDate and endDate and store them into previousTimingIDs
GetTimingIDs startDate ((current date) - 3600000) endDate (current date) with includeArchived

fetch IDs of all timings of task with ID and its subtasks and store them into previousTimingIDs
GetTimingIDs taskID "2724...27E3"

fetch IDs of all tasks (not including archived tasks) and store them info previousTaskIDs
GetTaskIDs

fetch IDs of all tasks and store them info previousTaskIDs
GetTaskIDs with includeArchived

fetch IDs of all tasks named ’t’ and store them info previousTaskIDs
GetTaskIDs name "t" with includeArchived

Trigger a script

To trigger your own AppleScript when a timer is started or stopped in Timeframe, create a file named ’timeframe_user_script.scpt’ and put it into the folder ‘~/Library/Application Scripts/com.timeframeapp.mac/‘.

In the file you must implement two methods:

on timerStartedForTiming(timingID)
tell application "Timeframe"
GetTimingWithID timingID
set taskID to relatedTaskID of previousTiming
GetTaskWithID taskID
set taskName to name of previousTask
say taskName
end tell
end timerStartedForTiming

on timerStoppedForTiming(timingID)
tell application "Timeframe"
GetTimingWithID timingID
set d to durationInSeconds of previousTiming as integer
say d
end tell
end timerStoppedForTiming
1 Like

Excellent!

1 Like