The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   iterate thru all current Inbox items (http://forums.omnigroup.com/showthread.php?t=30285)

gandalf44 2013-07-09 07:06 PM

iterate thru all current Inbox items
 
Trying to write an Applescript that will ( in the background) iterate thru all Inbox items, and pop up Growl notifications (I have that part of the code, just need help with Omnifocus inbox part). I would schedule thru Lingon X for this run say every 5min or so.

Reason is now with Mail Drop, I have a lot of stuff hitting my OF Inbox, and would like to see some Growl'dge :-) to remind me about it.

I've seen sample code for how to get a selected item from the inbox, but not to traverse all inbox items. I understand the repeat over a list concept, I just can't figure out the lexicon to iterate over the inbox list.

RobTrew 2013-07-10 12:20 AM

To visit all the actions in the Inbox, (iterating only through the leaves, and skipping their parent group nodes, if there is any indentation), you could write, for example, something like:

[CODE]tell application id "OFOC"
tell default document
set lstInboxLeaves to flattened tasks where in inbox is true and number of tasks = 0
repeat with oTask in lstInboxLeaves
set strName to name of oTask
end repeat
end tell
end tell[/CODE]

gandalf44 2013-07-10 06:36 AM

Thanks Rob!

RobTrew 2013-07-11 07:58 AM

FWIW if you just want a textual list of the items, you can get it directly without a loop.

[CODE]property pPrefix : "- "

tell application id "OFOC"
tell default document
set {dlm, my text item delimiters} to {my text item delimiters, linefeed & pPrefix}
set strList to pPrefix & (name of flattened tasks where in inbox is true and number of tasks = 0) as string
set my text item delimiters to dlm

strList
end tell
end tell[/CODE]

RobTrew 2013-07-11 08:17 AM

(Tho by the time you are doing that you might as well use a shell command line

[CODE]sqlite3 -separator " " ~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2 '
select "-", name from task
where effectiveinInbox=1 and childrenCount=0'[/CODE]

which is faster, and doesn't require OF to be running).


All times are GMT -8. The time now is 01:36 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2022, vBulletin Solutions, Inc.