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

 
Scripts that add simple tags to the end of notes... Thread Tools Search this Thread Display Modes
Hi guys,

I tried to suggest meta-tagging to the Omni guys... honestly, I'd prefer better printing onto 3x5 cards first, before meta-tags. ;) So, I hope they're working on printing...

But, I put together these two small scripts, which I hope to build upon over time. Basically these two scripts merely add the selected tag to the end of the notes for any single selected task. I decided to write one for Franklin type priorities, and one for Covey type time-Quadrants. [D. Allen has his own type of quadrant we could use instead...]

This may frustrate some people, merely because it's not very GTD, but I've already used it a few times to find higher priority tasks quite easily without using up Flags to mark them. Right now the scripts don't change the tags if you select a new one, they can only add tags from a note that isn't tagged with the same style of tag. [You can of course delete the tag yourself and start over.]

To find all your "A1" tasks, simply select "&A1" in the search window (or Q1,Q2 etc.)

Oh, they use Growl. You can see the code I had for non-growl use, but decided I was using it quickly enough without fault that I'd just run it in Growl instead.

Franklin Priorities:
Code:
set FranklinTasks to {"A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3"}
set AddFranklinTask to (choose from list FranklinTasks with prompt "Mark this task with priority: " OK button name "Mark" without multiple selections allowed and empty selection allowed)
set alreadyTagged to ""

tell application "OmniFocus"
	tell front document
		tell document window 1
			set theSelectedItems to selected trees of content
		end tell
		if ((count of theSelectedItems) = 1) then
			set selectedItem to value of item 1 of theSelectedItems
			set selectedNote to note of selectedItem
			
			set I to number of items in FranklinTasks
			repeat while (I is not 0)
				set tempItem to item I of FranklinTasks
				if selectedNote contains tempItem then
					set alreadyTagged to tempItem
				end if
				set I to I - 1
			end repeat
			
			--			if alreadyTagged is not "" then
			--				display dialog "This Task is marked: " & alreadyTagged & "Would you like me to change it?" 
			-- buttons ["No", "Yes"] default button 1
			--				set changeTag to button returned of result
			--			end if
			
			if alreadyTagged is not "" then
				--				display alert "This Task is marked: " & alreadyTagged & "Sorry, I cannot handle task-changing at this time."
				do shell script "/usr/local/bin/growlnotify OmniFocus Tagging -s -m 'Sorry, this Task is already marked: " & alreadyTagged & " (I cannot handle task-changing.)' -p 1"
				return
			end if
			
			if (alreadyTagged is "") or (changeTag is "Yes") then
				--				display dialog "Mark this project:" buttons ["Q1", "Q2", "Q3"] default button 2
				--				set selectedQ to button returned of result
				--				display dialog "I will now mark this project " & AddFranklinTask buttons ["Ok", "Cancel"] default button 1
				--				set tempresult to button returned of result
				--				if tempresult = "Cancel" then
				--					return
				--				else if tempresult = "Ok" then
				set newNote to selectedNote & return & "&" & AddFranklinTask
				set note of selectedItem to newNote
				do shell script "/usr/local/bin/growlnotify OmniFocus Task Tagged -m 'Task was successfully tagged as: " & AddFranklinTask & "' -p 1"
				--				end if -- Cancel or Ok the set Q
			end if -- if not already tagged
		end if -- if we are only dealing with 1 item
	end tell
end tell
Covey Quadrants:
Code:
set CoveyQuadrants to {"Q1", "Q2", "Q3", "Q4"}
set AddQuadrantResponse to (choose from list CoveyQuadrants with prompt "Mark this task with time-quadrant: " OK button name "Mark" without multiple selections allowed and empty selection allowed)
set alreadyTagged to ""

tell application "OmniFocus"
	tell front document
		tell document window 1
			set theSelectedItems to selected trees of content
		end tell
		if ((count of theSelectedItems) = 1) then
			set selectedItem to value of item 1 of theSelectedItems
			set selectedNote to note of selectedItem
			
			if selectedNote contains "&Q2" then
				set alreadyTagged to "Q2"
			else if selectedNote contains "&Q1" then
				set alreadyTagged to "Q1"
			else if selectedNote contains "&Q3" then
				set alreadyTagged to "Q3"
			else if selectedNote contains "&Q4" then
				set alreadyTagged to "Q4"
			end if -- already tagged if
			
			--			if alreadyTagged is not "" then
			--				display dialog "This Task is marked: " & alreadyTagged & "Would you like me to change it?" 
			-- buttons ["No", "Yes"] default button 1
			--				set changeTag to button returned of result
			--			end if
			
			if alreadyTagged is not "" then
				--				display alert "Sorry, this Task is already marked: " & alreadyTagged & "Sorry, I cannot handle task-changing at this time."
				do shell script "/usr/local/bin/growlnotify OmniFocus Tagging -s -m 'Sorry, this Task is already marked: " & alreadyTagged & " (I cannot handle task-changing.)' -p 1"
				return
			end if
			
			if (alreadyTagged is "") or (changeTag is "Yes") then
				--				display dialog "Mark this project:" buttons ["Q1", "Q2", "Q3"] default button 2
				--				set selectedQ to button returned of result
				--				display dialog "I will now make this project " & AddQuadrantResponse buttons ["Ok", "Cancel"] default button 1
				--				set tempresult to button returned of result
				--				if tempresult = "Cancel" then
				--					return
				--				else  -- if tempresult = "Ok" then
				set newNote to selectedNote & return & "&" & AddQuadrantResponse
				set note of selectedItem to newNote
				do shell script "/usr/local/bin/growlnotify OmniFocus Task Tagged -m 'Task was successfully tagged as: " & AddQuadrantResponse & "' -p 1"
				-- end if -- Cancel or Ok the set Q
			end if -- if not already tagged
		end if -- if we are only dealing with 1 item
	end tell
end tell
Hope you like them! :) Sorry if it frustrates someone! ;) [Prioritization is of limited use... I hope to have a simple tagging applescript for client names etc., setup in the near future to handle multiple selected tasks. I also need to work on tag-changing...]

Cheers!
-Allen

ps- for those who may see some of their own code in the above scripts, speak up, I may have forgotten where I got the code-snippet from!
 
Doh! I seem to be repeating everything! ach. Very nice work ptone!!
-Allen
 
when I run this script I get an error

"AppleScript reported the following error:
OmniFocus got an error: sh: /usr/local/bin/growlnotify: No such file or directory"


but if I hit 'ok' it runs....

When I search I get nothing

BUT
if I close and then search, it works

is there a way to make it work a little smoother?

thanks
 
I only get the error when the script is in the toolbar
 
You have to have growlnotify installed for the Growl portion of this script to work properly. And you have to ensure that growlnotify is available in your path so that when the shell command is called, it's able to be recognized from the system and run.

I suspect a path difficulty with growlnotify's location, or perhaps growlnotify is not installed.

If you are able to play with applescripts (highly recommended, they aren't horribly difficult), you'll notice the commented lines comment out a dialog box (you may need to swap a few lines here and there), that will turn on a display dialog instead of using GrowlNotify. :)

Ptone mentioned there's a bit fancier script version that might be a bit more robust for you in the link. :)

I'll try and alter the script and post it to not include growlnotify if you don't want to use growl.

Thanks for letting me know the difficulties you've had with the script. I hope that the above helps a bit!
-Allen

ps- MacOsX hints forum has some excellent discussions about path settings for command line work. The "do shell script" line is essentially the line that is running the growlnotify command. If you type that line (within the quotes) into your terminal window, it will have the same effect as running that small portion of the applescript code. There is however a slight difference between the terminal and non-terminal paths... which is why I mention the MacOsXHints forums' basic Unix info. I know this is a lot of info, but I thought you'd want to know what's happening in that line of the script. :) Again, feel free to comment that out and turn back on the display dialog portion of the applescript. I'll try and get that done here soon as well and repost it.
 
growl notify looks harder than I think I can comprehend
 
Hey LibraryMonkey,

Well, I have to admit that it's taken me years to become even mildly happy working in the terminal. :) I still haven't become a serious user of vi or emacs yet. :) So, I'm a youngling at terminal commands.

The path is really the critical setting... it's essentially just a location(s) where the unix underpinning of OsX looks for any programs. [A bit different than the OsX system... it needs to know where things are located... for instance: /usr/local/bin/ ] Since growlnotify is a unix program, it needs to know where it lives to launch it. I think a different trick could work. You can change the line that says: "do shell script..." to include the *path to the growlnotify program*. This way the system can know where it is to launch it. It looks like the location should be (after the install.sh has been run from the growlnotify folder included with growl): /usr/local/bin/ ha... and that's the same location as in my applescript. :( hmm... perhaps change it to just say growlnotify (without /user/local/bin/)... if the system knows where it is, it should automagically change it or just launch it. That may work!

If you try it out, let me know if it works. Again, it'd be /usr/local/bin/growlnotify to say: "growlnotify ..." alone. No /../../

Hope this helps! I'll definitely drop back on here and put up the display dialog version for you. I feel bad I didn't mention it required growlnotify to be setup right. :(

-Allen
 
I created paths
I ran terminal scripts

no luck

it probably is above me, thanks though

I have used it though
and changed it changing the A1, A2
to Call, write, research

so I can tag them with my tags and search accordingly
thanks
 
Hi Librarymonkey, I'm sorry that the little script isn't working perfectly for you. I'm working on a new one, and maybe will update this one to be a bit more simple... I'll try and post here when I have it completed. The main goal of the script was to do just as you were doing in your last message. So, I'm very glad that's working for you! :)

Wishing you well!
-Allen
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripts to open project folders and notes files jharrison OmniFocus Extras 57 2014-04-14 03:05 PM
Feature request: add simple text markups to iPad Notes editor Omen OmniFocus for iPad 1 2013-06-19 07:29 AM
Open Folder / Notes Scripts broken in Lion Full Screen Mode nunez OmniFocus 1 for Mac 3 2011-10-06 02:42 PM
Scripts: reorganizing outlines with popup tags RobTrew OmniOutliner 3 for Mac 0 2011-03-28 06:31 AM
Tool for making simple drawings while taking notes in OOP? UniAce OmniOutliner 3 for Mac 3 2007-11-08 01:53 PM


All times are GMT -8. The time now is 12:09 AM.


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