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

Script: custom OmniFocus action lists on the desktop, using Geektool Thread Tools Search this Thread Display Modes

My current preferences settings are:
"Due Soon" is in the next 2 days

Default Time For Due Dates: 5:00PM
I will check over the next day and see what happens.

Anyhow, I love the Geeklets. Awesome work.

:-) I'm glad you find them useful.

Given that our settings look the same, if you did find that you were getting a mismatch, attention might focus next on the data. (Are non-default due times involved, for example).

(With my data the geeklet lists do seem to be reliably matching the red and orange badging in OF).

Last edited by RobTrew; 2011-01-14 at 02:53 PM.. Reason: typo

Originally Posted by RobTrew View Post
No formal documentation that I know of, but you can put a list of the fields and their types into the clipboard with code like:

property pstrDBPath : "~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property plstResults : {}

on run
	set text item delimiters to return
	set str to ""
	set lstTables to ({"Task", "ProjectInfo", "Context", "Folder"})
	repeat with oTable in lstTables
		set strSQL to "PRAGMA TABLE_INFO(" & oTable & ");"
		set str to str & oTable & return & return & (plstResults as string) & return & return & return
	end repeat
	set text item delimiters to space
	set the clipboard to str
end run

on RunSQL(strSQL)
	set strCmd to "sqlite3 " & pstrDBPath & space & quoted form of strSQL
	set plstResults to (paragraphs of (do shell script strCmd))
end RunSQL
(Probably important to bear in mind that the schema can change, unannounced, between builds, and that reading the cache has been described on this forum as "at the deep end of not officially supported").
The other thing which may be useful to understand is the relationship between Applescript dates and the numeric datestamp strings in the cache. (Representing dates as a count of seconds since midnight at the start of 2001).

Here is a simple conversion function:

property pdteBase : missing value

on SQL2ASDate(strDateStamp)
		set intDate to (strDateStamp as integer)
	on error
		return missing value
	end try
	if pdteBase is missing value then
		set pdteBase to current date
		tell pdteBase
			set {its year, its month, its day, its time} to {2001, 1, 1, 0}
		end tell
	end if
	(pdteBase + intDate) as string
end SQL2ASDate

on AS2SQLDate(strDate)
		set varDate to date strDate
	on error
		return "null"
	end try
	if pdteBase is missing value then
		set pdteBase to current date
		tell pdteBase
			set {its year, its month, its day, its time} to {2001, 1, 1, 0}
		end tell
	end if
	(varDate - pdteBase) as string
end AS2SQLDate

Last edited by RobTrew; 2011-01-01 at 12:24 AM.. Reason: Added function for conversion from cache datestamp strings to AppleScript dates
and if you want to to interpret these OmniFocus dates (dateStamp strings giving a number of seconds since midnight at the start of 1 Jan 2001) without resorting to Applescript date functions, you can keep to SQL with expressions like:

select (strftime('%s','now') - strftime('%s','2001-01-01'));
for Now or Current Date,

select name, datetime(dateDue + strftime('%s','2001-01-01'), 'unixepoch') from task where dateDue is not null;
to convert a date field like dateDue to a human-readable string.
This could be really useful for other things except it appears to be saved as "Run Only". Was that intentional? It looks like people were able to view and edit earlier versions.
You should be able to download the script, open up Applescript Editor (or Script Debugger, if you have it), and have it open the script (or select the script and right-click to bring up the contextual menu, then choose Open with->Applescript Editor). I just did it with version 1.2 of the script, linked from the very first post in this thread.
It's conceivable that earlier versions of OS X might have difficulty reading a .scpt file created under 10.6

I have now supplemented the existing .scpt with a plain text (.applescript) version.

(See the post at the start of this thread).
Interesting. Both fail for me:

AppleScript Editor 2.3 (118) "Open Unable to read the file because the script is not editable (it was saved as run-only)."

Script Debugger 4.5: "The document "GeekOFSQL.scpt" could not be opened.

Other scripts downloaded from the forums work well for me (including a random one I tried just now from the 'Copy last sent message to Clippings' thread), and I consider myself fairly proficient with AppleScript.
Attached Thumbnails
Click image for larger version

Name:	Screen shot 2011-03-21 at 3.10.58 PM.png
Views:	487
Size:	30.7 KB
ID:	1828  
What is your OS version ?

(The recently added version is plain text, so you should have no difficulty with that).

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stencil: Custom circles of arrows (Shape with script Action) RobTrew OmniGraffle Extras 1 2013-07-29 07:28 PM
Single-Action Lists zakgottlieb OmniFocus 1 for Mac 2 2012-08-09 07:14 AM
Script to dump Omnifocus Context lists to Kindle? profdrhabeb OmniFocus Extras 2 2011-05-17 04:10 AM
Script to convert OmniOutliner row to OmniFocus Action JohnJ80 OmniOutliner 3 for Mac 0 2011-05-13 07:38 PM
On desktop banner of current action fathom OmniFocus 1 for Mac 26 2010-12-13 03:33 AM

All times are GMT -8. The time now is 11:14 AM.

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