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

 
Selecting new tasks via Applescript Thread Tools Search this Thread Display Modes
Once I make a new task using applescript, I'd like it to be selected for further editing. I tried this and it didn't work:

tell theProject
set thetask to (make new task with properties {start date:todayDate, name:subj, note:messagebody, context:theContext})
select thetask
end tell

Anyone have an idea how to make this work? I'm open to GUI scripting solutions.
 
The document itself doesn't have any support for selection; this is in the interface (since there can be multiple windows open, for one thing).

So, you can make and select a project like:

tell app "OmniFocus" to tell default document
set MyProject to make new project with properties {name:"My Project"}
tell sidebar of front document window
select {MyProject}
end
end

This will require that you have appropriate view settings (project mode, active projects). Also, if your focus set doesn't contain the project's folder, then the selection will fail with an error. Also, if you create the project in a folder that isn't expanded (or itself has an collapsed containing folder), then the selection apparently fails without an error. There is at least one bug in here... =)
 
Thanks for the response. However, I'd like to select a task, not a project. I'd really appreciate it if you could tell me how to select a specific task, both in project mode and context mode, assuming the task has both a project and a context assigned.
 
Ah; it should work with tasks just fine too -- you can do "select {MyTask1}" to select the task, but since tasks only show up in the content tree, you'd do:

tell content of front document window
select {MyTask}
end

to select the task. This works the same in project & context mode -- you can switch which mode the window is in by setting the document window's view mode identifier (there is a 'available view mode identifiers' list, currently just "project" and "context" and a 'selected view mode identifier').
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filtering by available tasks with AppleScript DGrady OmniFocus Extras 8 2012-11-20 01:41 PM
applescript for common OF tasks steve OmniFocus 1 for Mac 4 2012-02-15 05:11 AM
Applescript to get all tasks (when focused) mkko OmniFocus Extras 1 2011-07-11 12:44 PM
Applescript - Tasks vs. Tree - huh? syncretist OmniFocus Extras 2 2008-09-07 11:08 AM
Applescript Help: getting a list of tasks tweir OmniPlan General 3 2007-01-10 02:33 PM


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


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