Jump to content
Sign in to follow this  
Helmut Hauser

Keyboard shortcut to start apple script in Omnifocus

Recommended Posts

Dear all,

 

I would like to use Alfred 2 to start a specific Apple Script in Omnifocus. I tried to build a workflow, but I was not successful. I use a keyboard trigger, which should only work when Omnifocus is focused (I have adapted "Related Apps" accordingly).

I tried it with "Run Script" (using oascript with either coping and pasting the script and also by using the the path to the script) and I tried it with NSAppleScript (simply copy and pasted the script right into it) and it did not work :-(

 

Any suggestion?

 

Thank you very much for your help.

 

All the best,
Helmut

 

 

PS: Here is the script. It works when I call in Omnifocus. 

 

-- Downloaded From: http://c-command.com/scripts/omnifocus/defer-to-tomorrow

-- Last Modified: 2014-05-22

 

 

 

on run {}

repeat with _action in my selectedActions()

my processAction(_action)

end repeat

end run

 

on selectedActions()

tell application "OmniFocus"

return my filterValues(my selectedValues(), {inbox task, task, available task, remaining task})

end tell

end selectedActions

 

on selectedValues()

tell application "OmniFocus"

return value of selected trees of content of first document window of front document

end tell

end selectedValues

 

on filterValues(_values, _classes)

tell application "OmniFocus"

set _result to {}

repeat with _value in _values

if _classes contains _value's class then

copy _value to end of _result

end if

end repeat

return _result

end tell

end filterValues

 

on processAction(_action)

tell application "OmniFocus"

set _action's defer date to my calculateDate(_action's defer date)

end tell

end processAction

 

on calculateDate(_oldDate)

if _oldDate is missing value then

return my midnightTomorrow()

else

return (my midnightTomorrow()) + (time of _oldDate)

end if

end calculateDate

 

on midnightTomorrow()

set _date to current date

set day of _date to ((_date's day) + 1)

set time of _date to 0

return _date

end midnightTomorrow

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  
×
×
  • Create New...