Applescripts that made Omnifocus, Fantastical 2 and Tyme work together [time tracking]

If you want to set your goal, tracking time and record your life, you may want to try this :)

Apps you need: Omnifocus 2, Fantastical 2 and Tyme

###Preparation

  1. Set up projects in all 3 apps. (Set projects as separate calendars in Fantastical)
  2. Put the “omni_tyme” script in Omnifocus 2 script folder
  3. Put the “tyme_applescript_hooks.scpt” in ~/Library/Application Scripts/de.nulldesign.tyme.osx/ (You may need to create this directory)
  4. Create a button in Omnifocus toolbar
  5. [Alternative] If you have Alfred, there is an modified version of Omnifocus Create workflow made by me available below which will let you create last through Alfred and directly add the task to Tyme
    P.S. You may need to install these package through ‘’‘gem install XXX’’’ in terminal before using the workflow. bundler, plist, alfred-workflow, rb-appscript

###Workflow

  1. Create a task in Omnifocus with Estimated time, due date and a specific project
  2. Select the task and click the script button. The task will be created automatically in Tyme with estimated time, due date and project
  3. When you start to deal with the task, start Tyme for tracking time
  4. When you complete the task, stop time tracking and a new calendar entry will be automatically be created in Fantastical 2.

[If you are using alfred and the workflow above to input task, the step 2 can be ignored]

Hope you guys enjoy it!

Link (sorry…new users can only put 2 links in the post…)

omni_tyme
(https://github.com/fuxialexander/Applescript/blob/master/omni_tyme.scpt?raw=true)
tyme_applescript_hooks.scpt:(https://github.com/fuxialexander/Applescript/blob/master/tyme_applescript_hooks.scpt?raw=true)
Alfred Workflow
(https://github.com/fuxialexander/Applescript/blob/master/Omnifocus%20Create.alfredworkflow?raw=true)

###Credit
Alfred workflow “Omnifocus Create” Author: David Verhasselt

7 Likes

Looks like a great combination! One question:

stop time tracking and a new calendar entry will be automatically be created in Fantastical 2.

Does Tyme do that for itself (i.e. write to iCal), or have you scripted it?

Yep I scripted it. In the tyme_applescript_hooks.scpt file.

Thanks - I see it now…

This is really good. Is there anyway to add some logic so that it will check to see if the project name is already in Tyme and if it is not add it?

HAHAHA! I got it! The script is now updated. Enjoy yourself! (The color of newly created project can’t be controlled though).

sorry, seems the script need a little modify:

tell application “OmniFocus”
tell front window
set my_sel to selected trees of content
set my_selection to value of item 1 of my_sel
set tsk to name of my_selection
set due to due date of my_selection
set esti to (estimated minutes of my_selection) * 60 as real
set proj to name of containing project of my_selection
tell application “Tyme”
set judge to false
repeat with someproj in every project
if ((name of someproj) is proj) then set judge to true
end repeat
if (judge is false) then make new project with properties {name:proj}
end tell
tell application “Tyme” to make new task of (project proj) of application “Tyme” with properties {name:tsk, plannedDurationHours:esti, dueDate:due}
tell application “Tyme” to make new taskTag of task tsk of (project proj) of application “Tyme” with properties {name:“Incomplete”}
end tell
end tell

Now it works well.

1 Like

Working perfectly Thanks much, really improved my workflow!

This is sick.

Hey I’ve loved this script and it had been working perfectly between OF and Tyme, but with El Capitan it doesn’t seem to work any more…

Hello! Can you tell me which part didn’t work for you? I personally find no problem with the tyme-omni part.

Now it’s working fine!!! I don’t know why, could’ve been just a glitch on my side.

Thanks again for sharing your script! Looooove it!!!

Glad to see you loving it~

Hi, think you for this very useful post. How is it possible to mark a task as completed in Omnifocus when the task is marked as completed in Tyme and vice versa?

Thank you so much

I really want to implement that function, however unfortunately I have no idea how to realize it. I hope someone more capable in scripting can do this in the future.

1 Like