The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Applescript to Show Active Tasks Thread Tools Search this Thread Display Modes
Attached update is still an AppleScript. You can now keep items unsorted or sort list items first by keys (contexts).

version 1.2 (JJW)
	-- added ability to keep tasks unsorted
	-- changed simple_sort to shellsort algorithm
	-- added ability to sort by keys
	-- explicitly defined items going "as list"
Attached Files
File Type: zip (18.1 KB, 153 views)
A couple of small glitches initially prevented compilation and/or execution on my system:
  1. Some variation in spelling of mtcntxtStr (sometimes mtcntxStr)
  2. Any flagged tasks in inbox (containing project is missing value) not handled as currently drafted
PS to add a total to the header in some kind of bash version (to reduce any performance hit on the OF app, or to continue displaying lists when OF isn't running) you could do something like:

#OFOC=$(osascript -e 'tell application "Finder" to get id of application file id "OFOC"')
OFOC="com.omnigroup.OmniFocus" # For Appstore-purchased variant use (slower) line above instead
OFQUERY="sqlite3 $HOME/Library/Caches/$OFOC/OmniFocusDatabase2"
NOW=$($OFQUERY "SELECT (strftime('%s','now','localtime'))")
YEARZERO=$($OFQUERY "SELECT strftime('%s','2001-01-01')")

MATCHES="t.flagged=1 and t.dateCompleted is null 
	and (t.effectiveDateToStart is null 
	or ($YEARZERO + t.effectiveDateToStart) < $NOW)"


FROM ((task tt left join projectinfo pi on t 
left join task p on t.task=p.persistentIdentifier) 
left join context c on t.context = c.persistentIdentifier
ORDER BY,"| awk '
BEGIN {FS="\|"; prj=0; ctx=0;}
	# Output a [CONTEXT] header whenever 1st col value changes,
		if (ctx!=$1)  {ctx=$1; if (length(ctx) < 1) {print "(no context)"} 
		else {print "[" ctx "]"}}; 
	# and output a project name whenever 2nd  col value [PROJECT] changes,	 
		if (prj!=$2)  {prj=$2; if (length(prj) < 1) {print "\t(Inbox)"} 
		else {
			if ($3==$2) {print "\t " prj} else {print "\t" prj ":"}
	# and output column 3 [TASK] if it differs from col 2
		if ($3!=$2) {print "\t " $3}

Last edited by RobTrew; 2012-08-10 at 02:57 AM..
Thanks for the notes. A new version is attached with corrections.

version 1.3 (JJW)
-- corrected missing sort of 0 (no sort)
-- changed KeyList to words, not special characters
-- fixed misspelling of variable mtcntxtStr
-- checked for inbox tasks

Attached Files
File Type: zip (18.2 KB, 196 views)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Show active and on hold projects with script? mrubenson OmniFocus Extras 3 2012-01-04 11:01 AM
Perspective of Active Tasks ScottA83 OmniFocus 1 for Mac 1 2009-11-02 07:49 AM
Applescript to export each active project to a separate CSV signal15 OmniFocus Extras 0 2009-08-05 11:52 AM
Is there a way to hide active projects with no tasks? CatOne OmniFocus 1 for Mac 4 2009-07-20 03:37 PM
AppleScript: Set Active Workspace dennisffm OmniWeb General 3 2008-03-23 12:18 PM

All times are GMT -8. The time now is 05:27 PM.

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