TannieSpace

geekery, drawing and then some

Posts about list

Applescripts for OmniFocus: change the context or project of selected tasks.

I use OmniFocus a lot, and have recently tweaked some more AppleScripts to make my workflow even more smooth. I can add any mail to OmniFocus for replies, add confirmation of orders from mail to OmniFocus which will automatically go into my project-shoebox for orders, with a 'waiting for' context and a due date set to 1 week into the future, unless I've changed or added MailTags with a project, a keyword and a due date. In that case it'll take the project, the first keyword and the due date and use them to set up the OmniFocus task. I have a few more scripts:

  • in OmniWeb I can take and add a URL for later reading, it'll go into my inbox by default
  • in OmniWeb I can take and add a URL to my 'wish-list' project (with a start date for at 2 weeks in the future)
  • in OmniFocus I have scripts to easily change the context or the project of selected tasks
  • in Mail I can press a key and have the selected e-mail(s) sent to OmniFocus with a 'Respond to: ' before the subject line, sorting into either a default project or the one specified in MailTags, with the context set to 'mail' and the message URL in the note-field
  • in OmniFocus I can select such a task, press a key to run a script that will open the message and immediately create a reply (I have a separate one for just opening, in case I have to read it thoroughly first)

All these scripts make the integration between all these programs very easy. That and FastScripts. I found useful scripts over at Curtis Clifton's site. His scripts use Growl notification so if you have Growl installed you get a small notification.

I had some trouble putting my own scripts together, so I decided to paste the info here, just in case I need it later on, or someone else runs into similar issues. I found it quite hard to figure out how to add a task to an existing project or to move it from inbox / other project. In the end, it only took a few lines.

First, when I started my script, I wanted a default project or context (I'll use 'project' from now on, but it also applies to the context-script). To do this I created a 'property' at the beginning of the script:

property defaultProject : "Miscellaneous" property alertItemNum : ""

I used the alterItemNum for my alerts through this very simple routine:

on notify(alertName, alertTitle, alertText) display dialog alertText as string with icon 1 end notify

That went at the end of my script.

I started by addressing OmniFocus and 'talking' to the open document:

tell application "OmniFocus" tell front document tell (first document window whose index is 1)

Then, I checked to see if that document had anything selected, and if not, give an error-dialogue:

            set theSelectedItems to selected trees of content
            set numItems to (count items of theSelectedItems)
            if numItems is 0 then
                set alertName to "Error"
                set alertTitle to "Script failure"
                set alertText to "No valid task(s) selected"
                my notify(alertName, alertTitle, alertText)
                return
            end if

If I have no items selected, the script will call the alert routine from above ( my notify(alertName, alertTitle, alertText) ). Because I created a separate routine, I can use this anywhere in the script.

Next, display a dialogue asking for the project: ` display dialog "Change to what Project? " default answer defaultProject buttons {"Cancel", "OK"} default button 2

set theProject to (the text returned of the result) ` The variable 'theProject' will now contain the name of the (new) project to move the tasks too.

Next, the loop to go through all the items and move them:

            set selectNum to numItems
            set successTot to 0
            repeat while selectNum > 0
                set selectedItem to value of item selectNum of theSelectedItems
                set succeeded to my ChangeProject(selectedItem, theProject)
                if succeeded then set successTot to successTot + 1
                set selectNum to selectNum - 1
            end repeat

This loop will end as soon as the variable 'selectNum' (= numItems which I set to the count of the items in the variable SelectedItems) reaches 0. It calls the routine 'ChangeProject' which I'll get to in a bit, but I first want to wrap up this part. Let me also explain the 'if succeeded then set successTot to successTot + 1' line. The line before sets 'succeeded' to the result of the ChangeProject routine. This result can mean anything, numbers, letters, whatever. In this case we use it to return a 'true' or 'false'. That way, we only need to use 'if succeeded' (which will either be 'true' or 'false') as a condition. We don't need to check the actual content of the variable. This can come in handy for various checks, and it took me a while to catch on to that, so I figured I'd mention it here.

To end this main routine, I used:

            set alertName to "General" set alertTitle to "Script complete"
            if successTot > 1 then set alertItemNum to "s"
            set alertText to successTot & " item" & alertItemNum & " changed to Project " & theProject
        end tell
    end tell
    my notify(alertName, alertTitle, alertText)
end tell

Basically, this tells the dialogue box to say the script ran successfully and displays the number of items successfully moved and only to use the 's' after 'item' if the count of successful moves is higher than 1.

That wraps up the main part.

The routine to actually move the task to the other project only took 21 lines:

on ChangeProject(selectedItem, theProject)
    set success to false
    tell application "OmniFocus" to tell default document
        if (theProject is not "") then
            set MyProjectArray to null
            set MyProjectArray to complete theProject as project maximum matches 1
            try
                set MyProjectID to id of first item of MyProjectArray
                set theNewProject to project id MyProjectID
            on error
                set theNewProject to (make project with properties {name:theProject})
            end try

            try
                set newtask to selectedItem
                move newtask to end of tasks of theNewProject
                set success to true
            end try
        end if
    end tell
    return success
end ChangeProject

The first line sets the success to 'false', because we want to actively, after having our success, set it to 'true'. We then chat with OmniFocus again, and this time, we'll just talk to the default document (the one you have open). If the variable 'theProject' is not empty, we'll continue. If it is, the 'if-end if' ends, without having set the 'success' variable to true (and thus, the script failed). You could technically build in an extra loop to change it to a default project, however, I prefer it this way. If I accidentally emptied that dialogue-box, nothing will happen, just as I like it.

If theProject does contain something (anything), the script continues with its routine. It sets the MyProjectArray to null (makes it empty, just in case). It then used OmniFocus complete option to find the first matching project of OmniFocuses project-list. If you've ever only typed the first three letters in one of OmniFocus's project-areas (to set the project) and it magically came up with the right project, this is the same thing. It means you only have to type the first three or four letters of your project, and the script will find it. If it can't find the project, it will create it for you (at the end of your project-list).

After that, it will simply try to add the task to the desired project.


Shopping lists

img

[Updated: 2009-12-11: I no longer recommend Shopper, as of version 5.0. This paid app started to display ads and other cluttering info. See my newer post for more info ]

I generally make a shopping list when I go out buying groceries (about once per week). I used to go nearly every oter day, and spent money on food I hoped I could eat (but usually couldn't) which turned into one big waste pile which didn't feel good, money and waste wise. I put myself on a 'shopping list diet' basically, not buying anything that's not on the list. I check the pantry and the fridge before I go out and note what I need to buy. I read somewhere that if it wasn't important enough to put on your list while checking pantry and fridge, it's certainly not important enough to buy in the store just because you see it.

I do stray from this a bit, sometimes, when in the store I remember I need to buy dog-cookies (not in my pantry, so I don't see that I need too) or better, when they're on sale. I want to have a good enough stash of dog-food and treats for my dog. So occasionally I will stray from the list a bit, however, in general, the list really works. I have basically cut my grocery spending by at least 40% (yes, I did overspent horribly on groceries for a while).

For my shopping list making I've used Shopper for iPhone since September last year (and I admit I've strayed from the list a lot until last month, nothing to do with the program). I love the way it works, though I have flirted with other programs in the meantime. See, what I missed was the option to set the price based on store (to see where I could get the best deal). Realising today I had never e-mailed them to tell them that, I went to the website and found an entire page about Shopper v3 with all the functions I missed.

Now I can't wait for it to come out. I'm sure I'll love it. I love Shopper v2 for its simplicity already. Can only get better... ;)


To wishlist or not to wishlist.

Recently I started keeping a wishlist of things I wanted to buy, however, not just now. It also helps with having a 'cooling down' period after I decide I want-want-want something, as advised by many personal finance blogs out there (in one form or the other). At first I thought it was silly, I'd remember the things, but after using it for a while I found it actually really helps. Not only does this immediately stop me from impulse buying, it also helps me (eventually) buy more focussed. When I put an item on the list, I also put the price I found it for next to it, and where I saw it. Usually, I'll also add a photo to it. (I use Shopper on my iPhone, which I also use for my normal groceries). By adding the price, I can keep my eye open for a special offer for the same product, or, when I decide I really want to buy it, I can do focussed research to find the product at the best price.

I did do research before, especially for needed items, but my wants sort of slipped past that research stage more quickly. By keeping this list I force myself to not only wait, I also make sure I do plenty of research (and then in the process drop the product all together).

I've also noticed it becomes easier to throw things of the list after a while, and this in turn leads to it getting easier to not want to put something on there to begin with. Don't want to waste my time with things I won't buy anyway :) By seeing the silly stuff on my list, I feel less tempted by more silly stuff. And seeing the total amount doesn't hurt either!

I currently have 5 items on my list (I dropped some earlier): 1. Griffin Clarifi iPhone case 2. Neocube magnets 3. Sigg Thermo Mug 4. Portable foldable water-drinking reservoir for the dog 5. A 5x5x5 Rubik's Cube

All wants, I don't need any of them really. They're just so much fun! ;)


A few TODO-list pointers.

Today I read this article over at the Neat & Simple blog about ToDo-lists. Ariane explains we're all different people and we all have different ways to have a ToDo list work for us. We also all have different reasons why some things just don't work for us. She gives some great tips to create the list that works for you and find the right tools to do it.

I wanted to add my own experiences and tricks to it so I whipped up this post.

I've recently bought myself an iPhone (you may sigh/scream if you desire). My old phone started to fail and so did my palm. Combine this with my arthritis and enter iPhone. The touchscreen helps a lot with the arthritis. I started using OmniFocus as a trusted system months for my todos before that, and happily got the iPhone app when it became available.

What to use.

Now, it doesn't really matter if you use pen and paper or a computerprogram to make your lists, you should pick whatever works for you. For me, a computerprogram works best:

  • I change my mind a lot, pen and paper gets very very messy
  • A computerprogram lets me hide unimportant tasks with a few clicks / shortcutkeys
  • I can't write that much due to arthritis, typing goes a lot better
  • I can fit more info on my screen than on a reasonable piece of pape
  • I can use my phone to take notes and then sync up with my computer

If everything fails, power goes down and my phone drops dead, then yes, I'll use pen and paper. However, if that all happens at the same time I think I have bigger problems ;-)

My current setup.

So, I have a pretty simple setup:

  • OmniFocus on Mac laptop
  • OmniFocus on iPhone which alows me to note down tasks at any time.

How I write down tasks.

When I want to write down a task I take a few extra seconds to follow my 'pattern':

  • I always start with a verb, to put me in an actionable mood. The item is something I need to do, which requires a verb, so I put it in there straight away.
  • if it's a call, I use something like call John about project x and I'll look up the number straight away and copy-paste it into the item (as a note)
  • if for some reason I cannot look up the number straight away, I will always make an item before the original one stating where to find the number look up John's number in his letter Usually I know where to find it, so I'll make an extra note saying something like 'letter in archive' or 'letter on kitchen table'. I will link these items together. call John will become a subtask of look up John's number

By using a default 'template' for my actions it makes it easier for me to act on it. I know it will always say what to do (verb) with what / who (subject) about/for/because of what. If I feel like using a somewhat vague verb like 'think about' I'll take an extra minute to break it down a little into something I can actively do, and not passively. 'Thinking about' usually involves brainstorming (noting down any idea I have on the subject) and something like a pro/con list.

Beware of micro-tasking.

It takes some more time in the beginning to do this, but once you get used to it (and it fits your thinking) it'll help to clarify tasks and help you just do the task instead of having to look up that number, so you postpone it again. A successful todo-list will not make it hard on you to follow through, it will make it easy for you to do the task straight away. If you have to do things before you can actually start your task, then you should look into that, and perhaps make a task about it. Don't fall victim to micro-tasking though, you'll spend more time writing things down than actually doing it. Only you can decide where to draw the line in that. If you find you write down too little, try to do it a teensy bit more to see if you like it. And don't listen to those people who say that 'look up John's number' is a stupid task to write down, because of course you know you have to look it up. If you need to have it written down to keep going, by all means write it down. It sure saves me a lot of time and frustration and takes away the temptation of procrastination.