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 for finding an OmniFocus project quickly Thread Tools Search this Thread Display Modes
Quote:
I would begin by re-downloading the latest version (0.6)
Did That, doesnt help.

Quote:
What was the search you ran ?
Search that should return only 1 result.
It doesnt happens when search returns more than 1 result.

Quote:
Any OF windows already open ?
No

Quote:
Project view or Context view ?
Context View with focus

Quote:
How did you launch the script ? Launchbar ? Something else ?
Tool Bar

It doesnt happens when search returns more than 1 result.

Last edited by duracula; 2010-11-28 at 08:04 AM..
 
We seem to be posting at the same time.

Ver 0.7 above should help.

If not could you clarify something: not quite sure whether you are saying that no OF window is open, or that a Context view window is open.
 
Yep, it seem to help.

Thanks.

P.S Is there a way to do that the OK button in multi result will be focused, so it will be possible to just press enter and not using the mouse?
 
Quote:
Originally Posted by duracula View Post
Is there a way to do that the OK button in multi result will be focused, so it will be possible to just press enter and not using the mouse?
The OK button used to get the focus in OS X 10.5. Now, in 10.6, it seems to work if the script is launched from the Applescript editor, but not from the OF toolbar.

I have reported it as an error to OF > Help > Support

(might be worth adding a vote).

--

Last edited by RobTrew; 2010-11-28 at 12:31 PM..
 
Tapping the Return key suffices, incidentally, on my 10.6.5 system, if I launch the script from LaunchBar.

--

Last edited by RobTrew; 2010-11-28 at 12:31 PM..
 
Awesome work. I was wondering, since you already found a way to read the OF database itself, you could use the script to build a list of the projects in the database and export them. This would be the thing I have also been looking for to achieve some very fundamental "sync" between the project list in Omnifocus and MailTags.
 
Fairly straightforward if you just need a listing in a text file. Two main areas of choice:
  1. Which fields do you want to include, apart from the project name ?
  2. How should the fields be delimited : tab characters ? CSV ?

If you wanted to export any date fields, you would also need to choose a date format. You might also want to decide whether you really want every project in the database (including completed ones, for example), or just projects that have some particular status.

(Every now and then I spend a little time on a more general solution to this problem (an extension to Where in OF for generalised exporting, using an applescript-based query language rather than SQL) but a promise of water doesn't quench thirst, and the project is not advanced or high on my agenda, so I'm very happy to scribble something quick, simple and indicative in the meanwhile).

--

Last edited by RobTrew; 2012-07-17 at 06:08 AM.. Reason: Updated link to Where in OF
 
The bare elements might look something like this:

Code:
property pstrDBPath : "~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property pEOR : "<eor>"
property pstrFieldDelimiter : "<fld>"

property plstResults : {}

-- ADJUST THE LIST OF FIELDS REQUIRED, AND THE SORT ORDER ...
set strSQL to "select status, name from projectInfo p join task t on p.pk=t.projectInfo  order by status, name"

-- Specifically PROJECT fields:
-- containsSingletonActions	integer
-- folder	text
-- folderEffectiveActive	integer
-- lastReviewDate	timestamp
-- minimumDueDate	timestamp
-- nextReviewDate	timestamp
-- nextTask	text
-- numberOfAvailableTasks	integer
-- numberOfDueSoonTasks	integer
-- numberOfOverdueTasks	integer
-- numberOfRemainingTasks	integer
-- reviewRepetitionString	text
-- status	text
-- task	text
-- taskBlocked	integer
-- taskBlockedByFutureStartDate	integer
-- taskDateToStart	timestamp

-- Fields shared by projects and task
-- blocked	integer
-- blockedByFutureStartDate	integer
-- childrenCount	integer
-- childrenCountAvailable	integer
-- childrenCountCompleted	integer
-- completeWhenChildrenComplete	integer
-- containingProjectContainsSingletons	integer
-- containingProjectInfo	text
-- containsNextTask	integer
-- context	text
-- creationOrdinal	integer
-- dateAdded	timestamp
-- dateCompleted	timestamp
-- dateDue	timestamp
-- dateModified	timestamp
-- dateToStart	timestamp
-- effectiveContainingProjectInfoActive	integer
-- effectiveDateDue	timestamp
-- effectiveDateToStart	timestamp
-- effectiveFlagged	integer
-- estimatedMinutes	integer
-- flagged	integer
-- hasCompletedDescendant	integer
-- hasFlaggedTaskInTree	integer
-- hasUnestimatedLeafTaskInTree	integer
-- inInbox	integer
-- isDueSoon	integer
-- isOverdue	integer
-- maximumEstimateInTree	integer
-- minimumEstimateInTree	integer
-- name	text
-- nextTaskOfProjectInfo	text
-- noteXMLData	blob
-- parent	text
-- persistentIdentifier	text
-- projectInfo	text
-- rank	integer
-- repetitionString	text
-- sequential	integer


RunSQL(strSQL)

on RunSQL(strSQL)
	strSQL
	set strCmd to "sqlite3 -separator '" & pstrFieldDelimiter & "' " & pstrDBPath & space & quoted form of strSQL
	set text item delimiters to pEOR & return -- strip out the end of line \r as well as the record delimiter
	set plstResults to (paragraphs of (do shell script strCmd))
	
	set text item delimiters to pstrFieldDelimiter
	repeat with i from 1 to length of plstResults
		set item i of plstResults to text items of (item i of plstResults)
	end repeat
	set text item delimiters to space
end RunSQL


-- Do something with plstResults (a list of records, each of which is a list of fields)
set str to ""
set text item delimiters to tab
repeat with i from 1 to length of plstResults
	set str to (str & (item i of plstResults) as string) & return
end repeat

set text item delimiters to space
display dialog str
 
Rob,

Excellent. The tricky bit is that MailTags expects a plist format XML. But with that, we would be pretty close to the best possible integration (well, you would replace the project list with every important, but that should be fine).

The format for the plist seems to be as follows:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<dict>
		<key>count</key>
		<integer>1</integer>
		<key>preferred</key>
		<true/>
		<key>title</key>
		<string>project name 1</string>
	</dict>
	<dict>
		<key>count</key>
		<integer>1</integer>
		<key>preferred</key>
		<true/>
		<key>title</key>
		<string>project name 2</string>
	</dict>
</array>
</plist>
It seems that with the exception of the actual project name, the other values are pretty static. So ideally your script would produce a .plist, .xml or .txt in the above format, listing all remaining projects, basically ignoring all dropped or completed projects.

Do you think that would be possible?

Cheers,

-Sven
 
Quote:
Originally Posted by simplicitybliss View Post
MailTags expects a plist format XML.
I notice that Mail > Preferences > Mailtags > Projects > Import will import a simple text file list of project names (without XML tags)

but perhaps that is not what you are after ?

Can I ask you where this plist file is located, and what workflow you are aiming for ?

[This has drifted a bit off topic ... a new thread ?]
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding things quickly (and with confidence) in OmniFocus RobTrew OmniFocus 1 for Mac 8 2012-10-05 07:34 AM
How do I *quickly* re-file a task to another project? eatmytag OmniFocus 1 for Mac 7 2009-09-01 06:34 AM
Dead stoopid AppleScript question: finding the tell target jporten OmniFocus Extras 1 2009-03-19 10:10 AM
Help finding iCal applescript DoktorMarkus iCal Sync 2 2008-07-08 12:29 PM
Applescript OmniFocus to focus on one project Lutin OmniFocus Extras 4 2007-09-20 02:52 AM


All times are GMT -8. The time now is 02:50 PM.


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