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

 
Applescript request - Jump to Project Thread Tools Search this Thread Display Modes
Great Stuff, thanks Ken and Craig
 
So, is this working now? It sounds like a great idea. I was wondering if someone could copy/paste the code— it seems like there have been a few additions and I'm not quite sure where to add those.

Thanks,
Steve
 
Quote:
Originally Posted by steve View Post
So, is this working now? It sounds like a great idea. I was wondering if someone could copy/paste the code— it seems like there have been a few additions and I'm not quite sure where to add those.

Thanks,
Steve
Steve, yes it is working now. Also I modified it to work with LaunchBar. Here is the code without Launchbar support:

Code:
display dialog "Enter Project to Find" buttons {"Cancel", "Find"} default button 2 default answer "" with title "Project Find"
if button returned of result is "find" then
	set ProjectString to text returned of result
	tell application "OmniFocus"
		set MyDoc to default document
		tell MyDoc
			set MyProjectArray to complete ProjectString as project maximum matches 1
			set MyProjectID to id of first item of MyProjectArray
			set ThisProject to project id MyProjectID
			set newW to make document window with properties {focus:{ThisProject}, selected view mode identifier:"project", search term:""}
			set (selected smart group identifier of sidebar of newW) to "remaining-projects"
			set selected task state filter identifier of content of newW to "incomplete"
			-- set selected task state filter identifier of content of newW to "all"
			activate
		end tell
	end tell
end if
And here it is with Launchbar support...

Code:
on handle_string(ProjectString)
	if ProjectString is not "" then
		tell application "OmniFocus"
			set MyDoc to default document
			tell MyDoc
				set MyProjectArray to complete ProjectString as project maximum matches 1
				set MyProjectID to id of first item of MyProjectArray
				set ThisProject to project id MyProjectID
				set newW to make document window with properties {focus:{ThisProject}, selected view mode identifier:"project", search term:""}
				set (selected smart group identifier of sidebar of newW) to "remaining-projects"
				set selected task state filter identifier of content of newW to "incomplete"
				-- set selected task state filter identifier of content of newW to "all"
				activate
			end tell
		end tell
		open location "x-launchbar:hide"
	end if
end handle_string
I am going to enhance to accept some parameters like what filter settings to display and thing like that.

Thanks again for all the help.

George
 
I also prepended this
Code:
tell application "Quicksilver" to activate
to the Quicksilver script, as I was finding that when invoked the script via a Quicksilver trigger, the dialog wouldn't get the focus until I clicked on the bouncing Quicksilver icon in the dock.
 
Quote:
Originally Posted by Craig View Post
I also prepended this
Code:
tell application "Quicksilver" to activate
to the Quicksilver script, as I was finding that when invoked the script via a Quicksilver trigger, the dialog wouldn't get the focus until I clicked on the bouncing Quicksilver icon in the dock.
This is happening to me, too, when I try to invoke it using Quicksilver. I don't understand what you mean by prepending it to the Quicksilver script. What Quicksilver script?
 
Quote:
Originally Posted by mpw View Post
This is happening to me, too, when I try to invoke it using Quicksilver. I don't understand what you mean by prepending it to the Quicksilver script. What Quicksilver script?
I just meant the first script in post #13 immediately above mine. Before the "display dialog..." line, I added "tell application Quicksilver to activate".
 
Could someone help me figure out what to do with the pasted text. . . I am trying to get it to work with launchbar. Do I save the text as an applescript or something? If you could nudge me in the right direction, I would appreciate it.

Steve
 
Steve,

Below is an updated version of the script for LaunchBar. This one displays a dialog box if there are multiple matching projects, letting you choose between them.

To use with LaunchBar you need to:
  • Launch Script Editor.
  • Copy the script text into a new script.
  • Save the script to ~/Library/Scripts/Applications/OmniFocus/FocusOn.scpt
  • Make sure LaunchBar is configured to index your Scripts directory to arbitrary depth, you may need to go into LaunchBar config and click the Rescan button for Scripts

To trigger the script:
  • Activate LaunchBar
  • Type an abbreviation, like 'foc'
  • Press the space bar to enter text mode
  • Enter an abbreviation for the project. It should look something like this:
    Click image for larger version

Name:	Picture 1.png
Views:	485
Size:	10.7 KB
ID:	1123
  • Press the return key

Cheers,

Curt

Code:
(* Code due to gcrump (George) on the OF Extras forum.
	http://forums.omnigroup.com/showpost.php?p=37275&postcount=13
Updated to handle multiple projects by Curt Clifton.
*)

on run {}
	my handle_string("220")
end run

on handle_string(ProjectString)
	if ProjectString is not "" then
		tell application "OmniFocus"
			set MyDoc to default document
			tell MyDoc
				set MyProjectArray to complete ProjectString as project maximum matches 10
				if (count of MyProjectArray) is 0 then
					beep
					return
				else if (count of MyProjectArray) > 1 then
					set choices to my getNames(MyProjectArray, {})
					set choice to choose from list choices without empty selection allowed
					set MyProjectID to my getIDByName(MyProjectArray, item 1 of choice)
				else
					set MyProjectID to id of first item of MyProjectArray
				end if
				set ThisProject to project id MyProjectID
				set newW to make document window with properties {focus:{ThisProject}, selected view mode identifier:"project", search term:""}
				set (selected smart group identifier of sidebar of newW) to "remaining-projects"
				set selected task state filter identifier of content of newW to "incomplete"
				-- set selected task state filter identifier of content of newW to "all"
				activate
			end tell
		end tell
		open location "omnifocus:"
	end if
end handle_string

on getIDByName(XMLRecords, theName)
	if XMLRecords is {} then
		beep
		error "No record selected"
	end if
	set oneName to (name of item 1 of XMLRecords)
	log oneName
	if oneName is theName then
		return id of item 1 of XMLRecords
	else
		return getIDByName(rest of XMLRecords, theName)
	end if
end getIDByName

on getNames(XMLRecords, Accum)
	if XMLRecords is {} then
		return Accum
	else
		return getNames(rest of XMLRecords, ({name of (item 1 of XMLRecords)} & Accum))
	end if
end getNames
__________________
Cheers,

Curt
 
Curt, thank you for explaining how to set this up! That is a great tool. I love it.
 
Curt, Awesome update to the script. Much better application. How Can I get it to only search folder names instead of Project Names?
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyboard shortcut to jump to a particular project? ecf OmniFocus 1 for Mac 6 2011-07-06 03:09 PM
Jump to Project sprocketjockey OmniFocus 1 for Mac 5 2011-05-10 07:55 AM
Feature Request : Jump quickly from action to project alexjrice OmniFocus for iPhone 12 2011-01-02 02:11 AM
A way to jump from a task to its home project? jkorentayer OmniFocus 1 for Mac 4 2009-10-19 01:09 PM
jump to project from action? hexsprite OmniFocus for iPhone 4 2008-08-15 05:54 PM


All times are GMT -8. The time now is 09:08 PM.


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