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 Today's Posts

 
AppleScript Requests Thread Tools Search this Thread Display Modes
Here's a slightly improved version. It creates an invisible window to do the data extraction, so your existing windows aren't affected, and it handles the case of an action without a context.

Code:
property TargetPerspective : "Geek Tool" -- set this to the name of the perspective that shows desired actions

set taskList to ""
tell application "OmniFocus"
	tell default document
		set _window to make new document window with properties {visible:false} at front of document windows
		tell _window
			set perspective name to TargetPerspective
			set oTrees to trees of content
			set n to count of oTrees
			repeat with i from 1 to n
				set oTask to value of (item i of oTrees)
				set taskTitle to name of oTask
				try
					set projContext to name of context of oTask
				on error
					set projContext to "(No Context)"
				end try
				set taskList to taskList & " •    " & taskTitle & "  (" & projContext & ")
"
			end repeat
		end tell
		close _window
	end tell
end tell
return taskList
 
Quote:
Originally Posted by whpalmer4 View Post
Here's a slightly improved version. It creates an invisible window to do the data extraction, so your existing windows aren't affected, and it handles the case of an action without a context.
That is just brilliant whplamer4! Thank you! I had actually only just encountered the 'no context' problem and here you've already solved it for me. Moving the Perspective name to the start is handy too.

I'm really happy with this script now :) Should cover most eventualities and means the fact that mobileme iCal no longer works with Omnifocus is not an issue.
 
As a curiosity, here is an Sqlite version. Arguably less easy to maintain (the SQL queries are probably less transparent than applescript, and might need to be adjusted for later versions of OF).

On the other hand, it's rather short and simple, works even when OmniFocus is not running, and is quite fast.

Code:
property pstrDBPath : "~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property pstrFieldDelimiter : tab

set strQuery to "
select \"•   \", t.name, \"(No Context)\" from task t  where context is null order by t.name;
select \"•   \", t.name, c.name from task t join context c on t.context=c.persistentIdentifier 
where effectiveActive=1 and dateCompleted is null order by c.name, t.name;
"
set taskList to runquery(strQuery)

on runquery(strQuery)
	set strCmd to "sqlite3 -separator '" & pstrFieldDelimiter & "' " & pstrDBPath & space & quoted form of strQuery
	do shell script strCmd
end runquery

Last edited by RobTrew; 2010-11-20 at 04:11 PM..
 
I would second that I would really like a script that would read a text file and add an item from each line.

I use a script right now where I select each line and send it to LaunchBar. Launchbar makes a task in omni, and it accepts this form: task >project @context

If there were a way to put each line into this script... or each line within a certain marker? I'm not a programmer, it seems like an easy task, but I don't know.

The Launchbar script is at:

http://forums.obdev.at/viewforum.php?f=24
 
Quote:
Originally Posted by Noel Roy View Post
I would second that I would really like a script that would read a text file and add an item from each line.

I use a script right now where I select each line and send it to LaunchBar. Launchbar makes a task in omni, and it accepts this form: task >project @context

If there were a way to put each line into this script... or each line within a certain marker? I'm not a programmer, it seems like an easy task, but I don't know.
There are probably a number of variants out there, but something roughly like this would be one simple approach (for selecting several lines and using LaunchBar 'Instant Send' (dbl option tap, for example) to process them in one batch, making each line into a separate task).

Code:
-- LaunchBar script for parsing several lines of selected text to several tasks

on handle_string(str)
	tell application id "OFOC"
		if str ≠ "" then
			-- PARSE TASKS
			set lstParas to paragraphs of str
			tell default document
				repeat with oLine in lstParas
					parse tasks with transport text oLine
				end repeat
			end tell
			
			-- AND REPORT SUCCESS WITH A GROWL NOTIFICATION IF GROWL IS RUNNING
			my Growlify("Create OF Tasks from text", "OF Tasks created", ¬
				((count of lstParas) as string) & " tasks created in OmniFocus:" & return & return & str)
		end if
	end tell
end handle_string


on Growlify(strApp, strNote, strMsg)
	tell application id "sevs"
		if (count of (processes where bundle identifier is "com.Growl.GrowlHelperApp")) > 0 then
			tell application id "com.Growl.GrowlHelperApp"
				register as application strApp all notifications {strNote} ¬
					default notifications {strNote} ¬
					icon of application "OmniFocus"
				
				notify with name strNote title strNote ¬
					description strMsg application name strApp
			end tell
		end if
	end tell
end Growlify

Last edited by RobTrew; 2012-07-07 at 11:51 PM.. Reason: 'dbl opt click' --> dbl opt *tap* (for instant send)
 
Thank you so so much Rob!! This is totally amazing.

-Noel.
 
I'm looking for a fairly simple applescript. I want to take the currently selected project (or the project of the currently selected task) and send its attached contents to an Evernote name with the same name of the project (appending if it already exists).
 
Hi there.

I have a very very simple request. I just need an applescript that automatically sets the task that i am writing down in the QuickEntryWindow to repeat. How do I do that?

Sorry if the question is a bit dumb, but I can not find anything and my applescript knowledge is zero.

Many thanks, aeiou
 
 




Similar Threads
Thread Thread Starter Forum Replies Last Post
Perspective Requests Stephen Brown OmniFocus for iPad 4 2012-02-12 08:01 AM
Two requests gshenaut OmniFocus 1 for Mac 3 2011-01-08 09:06 AM
Feature Requests specialmoves OmniGraffle General 1 2008-06-26 03:54 PM
Feature/UI Requests Jon Hicks OmniWeb General 88 2007-03-15 02:08 PM
Few requests... thestaton OmniWeb Feature Requests 2 2006-11-15 12:57 PM


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


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