Show task in new window


#1

Can somebody please give me some suggestions on how to show a task in a new window?

This is the task that I have extracted:

Set MyTask to  task id "35678" of document id "adsfadf" of application "OmniFocus"

How do I show it in a new window?

Thanks in advance.


#2

I would like to know this too…


#3

Over a year later. Still no answer. This also parallels a request for option-open to show a task in a new window.

–> When can we expect to be able to do an (option)-control-click in a context menu to open a task in Project view in a new window?

Assuming the answer to at the above is … someday whenever we get around to putting this feature back from OF1 … then …

–> How do we use Applescript to open a selected task in a new window, preferably in Project view?


JJW


#4

This is the closest that I have found, courtesy of Dan Byler:

(*
	# DESCRIPTION #
	
	Inspired by OmniFocus 1 behavior, this script opens the selected task's (or tasks')
	project(s) in a new window so you can jump from a context view into the project view
	without losing place.
	
	# LICENSE #
	
	Copyright © 2015 Dan Byler (contact: dbyler@gmail.com)
	Licensed under MIT License (http://www.opensource.org/licenses/mit-license.php)
	(TL;DR: no warranty, do whatever you want with it.)
	
	# CHANGE HISTORY #
	
	1.0 (2015-04-28)
	-	Initial release

	# INSTALLATION #

	1. Copy script to OmniFocus script folder (OmniFocus -> Help -> Open Scripts Folder)
	2. (Optional) Update to use the icon in this repo
	3. Add script to the OmniFocus toolbar using View -> Customize Toolbar...
		
*)


on main()
	tell application "OmniFocus"
		set myFocus to {}
		-- get selection
		tell content of front document window of front document
			set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder)
			set totalItems to count of validSelectedItemsList
			if totalItems is 0 then
				my notifyWithoutGrowl("No valid task(s) selected")
				return
			end if
			repeat with validSelectedItem in validSelectedItemsList
				validSelectedItem
				if (containing project of validSelectedItem) is not missing value then
					set end of myFocus to (containing project of validSelectedItem)
				else if (assigned container of validSelectedItem) is not missing value then
					set end of myFocus to (assigned container of validSelectedItem)
				end if
			end repeat
		end tell
		
		-- no valid projects to focus on
		if length of myFocus is 0 then
			my notifyWithoutGrowl("No projects to focus")
			return
		end if
		
		-- make new window
		tell default document
			make new document window with properties {perspective name:"Projects"}
		end tell
		
		-- set focus
		tell front document window of front document
			set focus to myFocus
		end tell
	end tell
end main

on notifyWithoutGrowl(alertText)
	tell application "OmniFocus" to display dialog alertText with icon 1 buttons {"OK"} default button "OK"
end notifyWithoutGrowl

main()

#5

Superb! Thank you.

More to follow once I use this for my own script.


JJW


Select task from task id in applescript
#6

You can create a new window, then use GetURL to have that window focus on the task in question:

tell application "OmniFocus"
	tell default document
		set MyTask to task id "35678" -- or whatever you've done to get MyTask
		set MyTaskURL to ("omnifocus:///task/" & (id of MyTask))
		tell (make new document window)
			GetURL MyTaskURL
		end tell
	end tell
end tell

Hope this helps!


#7

This script will take a selection and open it in a new project window. The next step might be to modify it to (try to) close the tool bar and the sidebar. I think this can only happen through AppleEvents.

on run
	tell application "OmniFocus"
		
		tell content of front document window of default document to set MyTask to the value of every selected tree
		
		tell default document
			set MyTaskURL to ("omnifocus:///task/" & (id of first item of MyTask))
			tell (make new document window)
				GetURL MyTaskURL
			end tell
			
		end tell
		
	end tell
  end run


JJW


Re-create "Show in Projects" and "Show in Contexts" via Applescript?
#8

Dan Byler’s script is fantastic, given that double-clicking is not an option. However it does not display completed tasks. Does anyone know how to make it display all the tasks in the project?


#9

The simplest way I can think of to accomplish seeing a task in the context of its project with all completed tasks showing is this:
Set the Projects perspective to show All and save the perspective.
Open the project of the task in question with Cmd-O. Voila: a new window with that project and all tasks showing.

Maybe Dan Byler’s script also relies on the Projects perspective…


#10

Cmd-O requires typing the name of the project. Dan Byler’s script is two clicks. Select an action, click on his icon. Not as good as the double-click method in OF1, but better than Cmd-O for me.

However I’m less concerned about this than I was. Now I use Dan Byler’s for actions, and the OF2 focus command for projects. That more or less does what I want.


#11

I now understand what you were saying. Setting the Projects perspective (which I never use) to All does affect the result of Dan Byler’s script. Thanks!