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
George,

OF's complete command that does the search only supports searching for projects and contexts. So searching folder names is a significant change. You'd need to scan through the whole tree under Library looking for folders. (My my Verify Next Actions script has code that could be modified to do that.) Once you found a folder, you'd have to see if it matched the input pattern. Something like name of theFolder contains theSearchPattern would find exact matches, but you wouldn't get the approximate matching that the complete command provides.

Cheers,

Curt
__________________
Cheers,

Curt
 
Curt, Thanks for the quick reply. Figures it wouldn't be easy :) Oh well I do have your next actions script so I'll work through that. By the way heavy user of your populate template script. Thanks very much for that huge time saver.
 
Quote:
Originally Posted by gcrump View Post
How Can I get it to only search folder names instead of Project Names?
George's idea seemed useful, but adding it to the existing Focus On script was too slow. So, I created a new script "Focus on Folder" that works essentially like the existing one described above, but only searches folder names.

One other difference: the text entered for the search must be appear as contiguous characters in the folder name. That is, a search for “UFO” would match “Documented UFO sightings” but would not match “Founded Ungulates For Obama”. Without a built-in complete command for folder names anything but exact substring matching is too slow.

Here's the new script. Install it and use it like the other one, but call it something different so you can use both scripts.

Code:
(*
	This script lets you use LaunchBar to open a new OmniFocus window focused on
	a folder that matches a given string.
	
	by Curt Clifton, portions derived from code due to gcrump (George) on the 
	OF Extras forum.
	
	http://forums.omnigroup.com/showpost.php?p=37275&postcount=13
 
*)

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

on handle_string(FolderString)
	if FolderString is not "" then
		tell application "OmniFocus"
			set mainDoc to default document
			set omniFocusFolders to my getFolders(FolderString, mainDoc)
			tell mainDoc
				if (count of omniFocusFolders) is 0 then
					beep
					return
				else if (count of omniFocusFolders) > 1 then
					set choices to reverse of my getNames(omniFocusFolders, {})
					set choice to choose from list choices without empty selection allowed
					set folderID to my getIDByName(omniFocusFolders, item 1 of choice)
				else
					set folderID to id of first item of omniFocusFolders
				end if
				set folderObject to folder id folderID
				set newW to make document window with properties {focus:{folderObject}, 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 getFolders(FolderString, omniFocusDocument)
	using terms from application "OmniFocus"
		tell omniFocusDocument
			set theSections to every section whose class is folder
			return my accumulateMatches(FolderString, theSections, {})
		end tell
	end using terms from
end getFolders

on accumulateMatches(FolderString, theFolders, Accum)
	if (theFolders is {}) then
		return Accum
	end if
	return accumulateMatches(FolderString, rest of theFolders, accumulateMatchesHelper(FolderString, item 1 of theFolders, Accum))
end accumulateMatches

on accumulateMatchesHelper(FolderString, aFolder, Accum)
	using terms from application "OmniFocus"
		if (my matches(name of aFolder, FolderString)) then
			set Accum to {aFolder} & Accum
		end if
		set theSubfolders to every section of aFolder whose class is folder
		return accumulateMatches(FolderString, theSubfolders, Accum)
	end using terms from
end accumulateMatchesHelper

on matches(folderName, matchString)
	return folderName contains matchString
end matches

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, Great addition to the library. Thanks a ton!
 
Bump. (Sorry for the noise, but I spoke with someone today and mentioned this script. I didn't have the URL at hand in the conversation, but said that I'd bump the thread to the top of the forum.)
__________________
Cheers,

Curt

Last edited by curt.clifton; 2010-06-07 at 12:50 PM.. Reason: Removing redundant post, bumping thread
 
Thanks Curt!!!

I am downloading laundbar now and I will see if there is any documentation in how to install the script there.

THANKS!!!

Edward
 
FWIW here is the script which I use for refocusing on a particular folder through Launchbar ...

It is a little simpler than Curt's excellent script, but runs very snappily, which reduces a little of the cognitive friction for me ...

(Simply refocuses the current window on the specified folder, and uses a slightly faster approach to find the first folder with a name that contains the substring typed in Launchbar)

Code:
(* 
	Run from Launchbar to refocus current window on a folder
	specified by entering a substring of the folder name  in Launchbar.
	
	If the script is indexed in and summoned from Launchbar,
	tapping spacebar will allow you enter enough of any substring 
	of the folder name to uniquely identify it.
	
	A simple approach, but runs quite snappily, for those who like that kind of thing :-)
*)

property pstrTitle : "Focus on folder"

on handle_string(strFolderName)
	if length of strFolderName > 0 then
		tell application id "com.omnigroup.OmniFocus"
			set oDoc to default document
			
			set oFolder to my FolderByName(oDoc, strFolderName)
			if oFolder is not missing value then
				set focus of front document window of oDoc to {oFolder}
			else
				display dialog "No folder with name containing " & ¬
					strFolderName & return & "found in the OF database" with title pstrTitle
			end if
			activate oDoc
		end tell
	end if
end handle_string

on FolderByName(oParent, strName)
	using terms from application "OmniFocus"
		set lstMatches to folders of oParent where name contains strName
		if length of lstMatches > 0 then
			return first item of lstMatches
		else
			set lstFolders to folders of oParent
			repeat with oFolder in lstFolders
				set varResult to FolderByName(oFolder, strName)
				if varResult is not missing value then return varResult
			end repeat
		end if
		return missing value
	end using terms from
end FolderByName

Last edited by RobTrew; 2010-06-07 at 10:49 PM..
 
Hi Curt and RobTrew, thanks for the scripts.

The only thing is that for the las 90 minutes I have been searching how to install a script in omnifocus. I found a thread that here that showed me how to get the applescript icon on the SL menubar. I did.

Then to identify my script folder on the ~/scripts/application/ and so on.

Well, I actually called apple care because I did not have a "scripts" folder under my username on my imac. They directed me to hard disk, and there it was.

My next questions are:

1) Will these scripts run well, even if they are not under my username folder, but on the harddiskname/scripts/ and so on?

2) I see that the scripts that both of you are providing are, of course, a code ( a series of instructions ). Am I supposed to saved this as a file or Am I supposed to saved the code on a folder?

My question tells you how new I am on this "scripting business" ;-)

3) I just downloaded launchbar. If there is an easy way to intall this there, please, let me know. I am really confused with this, however, being able to search for a folder is very important for my workflow.

Thank you both for your kind help!!!!

Edward
 
I just found this from Curt:

"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: 9 Size: 10.7 KB ID: 1123
* Press the return key


Cheers,

Curt"


I think that answers some of my questions. I will try it to see if it works.

I keep wondering if there is any difference to run the scrips from my harddisk as opposed from my username folder.

Thanks,

Edward
 
Quote:
Originally Posted by edwardro View Post
I keep wondering if there is any difference to run the scripts from my harddisk as opposed from my username folder.
Script behaviour is not affected by the location of the script file, but placing it in a folder like [Your UserName]/Library/Scripts/Applications/OmniFocus does have the advantage that the script will then appear in the OmniFocus scripts menu, and can easily be installed on your toolbar.

There is a summary of script installation in another thread.
 
 


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 03:23 AM.


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