The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Scripting QuickEntry (http://forums.omnigroup.com/showthread.php?t=4979)

curt.clifton 2007-09-26 02:19 PM

Scripting QuickEntry
 
I see some AppleScript dictionary support for QuickEntry in the latest build. Anyone figured out how to open the QuickEntry window from AppleScript yet?

Tim Wood 2007-09-26 05:39 PM

Heh; I was just about to come post something about this.

Here are some examples:

[code]
tell app "OmniFocus"
tell quick entry
-- activate the quick entry panel for the default document
-- unlike the UI hook this won't add the default empty task
activate
end
end
[/code]

[code]
tell app "OmniFocus"
tell quick entry
make new inbox task with properties {name:"foo"}
select {task 1}
save -- saves, closes and clears the panel as if you'd hit the 'Save' button
end
end
[/code]

[code]
tell app "OmniFocus"
tell quick entry
close saving no -- discards the data; yes saves
end
end
[/code]

[code]
tell app "OmniFocus"
tell quick entry
close -- with no 'saving' specified, just hides the panel w/o saving or reverting the data.
end
end
[/code]

The 'delete' command and tree suite should be supported too (quick entry is a subclass of tree in the script suite), though I've only tested the select command so far.

All the rich text & attachment scripting should work too on task notes as well, but it's received only limited testing in the Quick Entry configuration (the code is nearly all shared, so if something is busted it should be pretty easy to fix).

I still need to support the 'complete' command and as of yet, trying to assign a context or project to an inbox item will not work if you try to mix-n-match objects from different documents (where quick entry acts like a little document of its own). You could probably work around this (untested) by finding the project/context you want in the main document and then doing something like:

[code]
tell quick entry
set context of MyTask to context id (id of MyContextFromDocument)
end
[/code]


I would like to find time to auto-map these sorts of assignments, but I don't know if I'll find time before 1.0.

Tim Wood 2007-09-26 05:44 PM

I should also mention that what I'm working on [b]now[/b] is a clipping service with support for post-clipping script handlers to make cleanup/extensions to the clipped text based on the active application's state.

I'm out of town next week and I don't know if this will be committed before I go -- hopefully!

millieaux 2007-10-03 08:36 AM

Anyone have any luck with this? I tried modding Curt's Mail script to open the Quick Entry and just start a new entry with title & note, but it's not working for me - even just opening the Quick Entry doesn't seem to work!

I get:
[CODE] open quick entry
"OmniFocus got an error: Can't make quick entry into type file."[/CODE]

curt.clifton 2007-10-03 02:23 PM

I get the same thing for [I]open[/I]. I can get the 'make new inbox task' command to work on the QE window. Select and save also work. I opened the QE window using the hotkey, then ran this script:

[CODE]
tell application "OmniFocus"
tell quick entry
make new inbox task with properties {name:"foo"}
select tree 1
end tell
end tell[/CODE]

That part works. I'm guessing that Tim might have missed one commit before heading out so that the open command isn't implemented. I'll report via Send Feedback.

Tim Wood 2007-10-09 08:15 PM

Bah; that's what I get for posting and then leaving for a week.

It turns out this works fine on my machine running 10.5, but not so much on 10.4 and I failed to run the test suite on 10.4 before claiming this worked.

Sorry for the false alarm -- I'll look into it.

Tim Wood 2007-10-09 08:45 PM

OK, this should be better as of 92548. I've switched to using 'activate', which doesn't assume that its direct parameter is a file or list of files. No idea why this worked on 10.5... this is what I wanted to use in the first place, but then I got distracted and used 'open'.

I'll update the example above too for posterity.

curt.clifton 2007-10-10 02:40 PM

Tim, we're almost there.

Here's what I almost have working now:

[CODE]
tell application "OmniFocus"
tell quick entry
-- Need to make task before activating or we get two tasks
make new inbox task with properties {name:"foo", note:"bar"}
activate
-- Need to use tree 1, rather than {task 1} as in
-- posted example
select tree 1
set note expanded of tree 1 to true
end tell
end tell
[/CODE]

If I activate before making the new task, then I get two tasks: the "foo" task added by the script and a new empty task.

If I add the task before activating, then the task pane in the QE window does not have focus. That necessitates a trip to the mouse in order to edit the new task.

Also, no joy in setting the context of the QE task.

Adam Sneller 2007-10-10 09:28 PM

Send Mail to Quick Entry
 
Here is a script I wrote that sends a selected mail message to the Quick Entry panel. This will create a new task with a name set to the subject line of the email and the content of the message as a note. Seems to work pretty good.

The only thing I don't like is that, when Quick Entry opens, the buttons have focus. Anybody know how to shift focus to the task window?

Hope this helps!

[CODE](* New OmniFocus Action from Mail.app Message

Written by Adam Sneller
Copyright October 10, 2007. All rights reserved.

Version 1.0

*)

tell application "Mail"

-- get the currently selected message(s)
set these_messages to selection

-- if there are no messages selected, warn the user and then quit
if these_messages is {} then
display dialog "Please select a message first and then run this script." with icon 1
return
end if

-- loop through messages
repeat with this_message in these_messages

-- create link to message
set this_link to "message://" & (message id of this_message as string)

-- create task content and link to message
set this_subject to subject of this_message
set this_content to this_link & return & return & this_subject & return & date received of this_message & ¬
return & return & content of this_message

-- send task to OmniFocus
my pushToQuickEntry(this_subject, this_content)

end repeat
end tell

on pushToQuickEntry(get_name, get_note)
tell application "OmniFocus"
tell quick entry
set this_task to make new inbox task with properties {name:get_name, note:get_note}
select {this_task}
activate
end tell
end tell
end pushToQuickEntry[/CODE]

curt.clifton 2007-10-11 04:15 AM

Adam, I'm not sure if you were trying to help me here, but the problem I'm having is the same one you're having. The tasks in the QE window don't have focus. (I've had the Mail side of it licked since June. See that script and my others on my [URL="http://www.rose-hulman.edu/~clifton/software.html"]software downloads page.[/URL])


All times are GMT -8. The time now is 12:59 PM.

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