PDA

View Full Version : Applescript: Searching for tasks that fit specific requirements


a11en
2008-01-10, 10:03 PM
Hi guys,

I was wondering a few things about the Applescript implementation. (you may be able to see where I'm going with this eventually)...

I've learned some simple stuff with a few moments of playing... I can get selected task information, I can set selected task information. I can also get top window search-term text and set top window search term text.

But, here's a big Q... is it possible to get OmniFocus to return all tasks which fit specific search requirements? For instance, can I set all aspects of filters and search-terms via applescript and return (to the user in the omnifocus window forefront) the tasks which are visible in the top window that meet said search and filter requirements?

Thanks for your thoughts on this. If you need more clarification of what I'm meaning here, please let me know.

Cheers!
-Allen

RobTrew
2008-01-11, 06:42 AM
Take a look at the settable properties of the Content Tree in the OF applescript dictionary, from selected grouping identifier onwards.

a11en
2008-01-12, 07:54 PM
Thanks Rob! I was able to get somewhere. I'll keep working on it. :) Thanks!

a11en
2008-08-30, 05:33 PM
Hmm.. I'm having trouble figuring out how to script these... can't seem to get these items to view them... can anyone shed light on setting these tree items etc.,?

curt.clifton
2008-08-30, 06:33 PM
Here's a snippet of code lifted from my Where To Focus widget (http://www.rose-hulman.edu/~clifton/software.html). This is edited for clarity, but not tested:


tell application "OmniFocus"
tell front document
set theWindow to first document window
tell sidebar of theWindow
if showOnlyActiveContexts then
set selected smart group identifier to "active-contexts"
else
set selected smart group identifier to "available-contexts"
end if
end tell
tell content of theWindow
set selected grouping identifier to groupingIdentifier
set selected sorting identifier to sortingIdentifier
set selected task state filter identifier to taskStateFilterIdentifier
set selected task duration filter identifier to taskDurationFilterIdentifier
set selected task flagged filter identifier to taskFlaggedFilterIdentifier
end tell
end tell
end tell


The variables at the end of the last 5 set lines (groupingIdentifier, etc.) are used to set the view bar lozenges. A corresponding command, get available grouping identifiers will give you a list of the allowed values for the variable.

a11en
2008-08-30, 06:50 PM
Hey Curt,

Excellent, thank you for the code examples. Nothing helps like code examples! :) I'll keep playing.

Essentially I want to set the various selected task filter settings on the main window through a script... and I think you are doing so right here, so I think this is to the point. :)

I greatly appreciate your help!!
-Allen

ps- where to focus is quite awesome- this is *exactly* the type of thing that leverages the power of our computers.