I don't think there are any hacks to it. It takes time to get into the zone. Most of the time where I care about this, or pay attention to it, it's because I have to work on something I don't want to work on, but must get done. There are some hacks to it. Invariably, I find that once I get started, and once I'm finished, it wasn't as bad as I thought it would before I started. Something like working on a lame feature my product person or sales team insists we need, but I don't want to do it because it involves tracking cookies or session state and transfering that state over to a user's profile after they've logged in.

I have a few tricks to get myself started on tasks like this. First, is to close the browsers, and close everything except my IDE and the other development tools I need for the task. Close any other code projects that aren't directly related. A reboot often works. Then, I'll open a clean .txt file and just start writing, sort of stream of conscious style, about what I have to do. It helps to get a once sentence objective down on paper or on the screen, because when I'm unmotivated it's very easy to lose focus and move onto something else, so having that objective written down on paper helps remind me what I'm supposed to be doing. If the task is big enough I'll break it into smaller ones and write those down. Each task should be it's own self contained problem.

Most often when I am unmotivated it's ebcause I have to research before I can proceed with a task, and while I like research, if it's not something I'm into I'll still have a hard time motivating myself to do the research. So for each task, if there is something I don't know, I'll write out what I need to do, what I need to figure out, and if I know of different approaches to solving the problem I'll list all of them out and list the pros and cons for each one. Once that's on paper, it's usually pretty clear what the way forward is. If there are open questions, i'll put tasks to research them.

This sounds tedious but it normally takes less than 10 minutes to do, and i end up with a list of tasks, that are either research based, or implementation based. And I get started on them. I mark them each "DONE" (or cross them out if using paper) as I go along. And of course I order them such that anything that needs to be figured out before working on other stuff is done first.

This sounds pretty obvious, but when you're not feeling motivated I find this helps. It's basically a process that parallels onto paper/.txt what you do mentally when you're in a flow state. But when you're unmotivated, it's hard to keep track of all that because you keep getting distracted. This is a good way to finish and fight out getting things done. No matter how interesting a project is, there are always pieces to it that are non-glorious and a process like this helps.

Aside from that, I just like to have a routine set up. Sit down at the computer and just start working. Being able to force yourself to do something you aren't that into doing is a GREAT skill to have, and you can improve it over time with practice. You can also lose it by not practicing.

Another thing that helps, is before leaving the computer from a work session, I write down a few lines in Evernote. It just looks like this:

Where I left off, 2013-01-18 (before leaving cafe Thursday night):
- Just finished figuring out how to store the user data in cookies, but there might be problem with the way it's saving. I think I should track when the data is changed and only .Set() the cookies when the data has changed, and I need to track it for each set of values so that they don't wipe each other out.
- still need to do XYZ
- remember to merge into master for the release I just did, and push everything

It's just a two minute recap of the last thing I was working on, and what I wanted to work on next. I find that this helps me a lot to pick back up faster the next time I come to the computer to do some work.