The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Applescript for finding an OmniFocus project quickly (http://forums.omnigroup.com/showthread.php?t=18580)

duracula 2010-11-28 08:02 AM

[QUOTE]I would begin by re-downloading the latest version (0.6)
[/QUOTE]
Did That, doesnt help.

[QUOTE]What was the search you ran ?
[/QUOTE]Search that should return only 1 result.
It doesnt happens when search returns more than 1 result.

[QUOTE] Any OF windows already open ?
[/QUOTE]No

[QUOTE]Project view or Context view ?
[/QUOTE]Context View with focus

[QUOTE]How did you launch the script ? Launchbar ? Something else ?
[/QUOTE]Tool Bar

It doesnt happens when search returns more than 1 result.

RobTrew 2010-11-28 08:35 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.

duracula 2010-11-28 09:19 AM

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?

RobTrew 2010-11-28 09:50 AM

[QUOTE=duracula;89550]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]

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).

[COLOR="White"]--[/COLOR]

RobTrew 2010-11-28 12:18 PM

Tapping the Return key suffices, incidentally, on my 10.6.5 system, if I launch the script from [URL="http://www.obdev.at/products/launchbar/index.html"]LaunchBar[/URL].

[COLOR="White"]--[/COLOR]

simplicitybliss 2010-11-30 11:33 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.

RobTrew 2010-12-01 12:26 AM

Fairly straightforward if you just need a listing in a text file. Two main areas of choice:[LIST=1][*]Which fields do you want to include, apart from the project name ?[*]How should the fields be delimited : tab characters ? CSV ?[/LIST]
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 [URL="http://bit.ly/OF-Find2"]Where in OF[/URL] 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).

[COLOR="White"]--[/COLOR]

RobTrew 2010-12-02 03:47 AM

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
[/CODE]

simplicitybliss 2010-12-05 11:02 PM

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>[/CODE]

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

RobTrew 2010-12-06 03:49 PM

[QUOTE=simplicitybliss;89997]MailTags expects a plist format XML. [/QUOTE]

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 ?]


All times are GMT -8. The time now is 07:05 AM.

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