Omni
2008-03-27, 03:24 PM
launching OmniFocus if it wasn't running was something the customer was looking for, but yeah - if you don't want that, another way would be more appropriate.
Customer had one more request, so tweaked the script a bit more. It now
a) finds a window pointed at your default document (if you have more than one window open) and brings that forward.
b) switches that window to project mode if you're in context mode
c) adds the inbox to your sidebar selection if it isn't already selected.
Code:
set itemText to display dialog "Enter text you'd like to add to OmniFocus:" default answer ""
set newItem to text returned of itemText as Unicode text
tell application "OmniFocus"
tell default document
make new inbox task with properties {name:newItem}
end tell
set defDocID to id of default document
set defDocWindow to ""
repeat with w in windows of it
set d to document of w
if d is not missing value then
if id of d is defDocID then
set defDocWindow to w
exit repeat
end if
end if
end repeat
if defDocWindow is "" then
set filePath to file of default document
set defDoc to open filePath
tell defDoc
set defDocWindow to make new document window
end tell
end if
set selected view mode identifier of defDocWindow to "project"
tell sidebar of defDocWindow
set selected of inbox to true
end tell
activate
end tell
Last edited by Brian; 2008-03-27 at 05:07 PM..