When to automate a repetitive task:

NO-BRAINER: "This is obviously going to be faster to automate than to do it by hand _even once_. Let's automate it right now, and not do it by hand at all."

FORESIGHTED: "Doing it once by hand is faster than automating it, but I'm going to have to do it a lot of times, so it still saves time to automate it first."

NEED A RUN-UP: "I don't yet understand this task well enough to automate it, so I'll do it a few times by hand first to get the idea."

RAN OFF THE RUNWAY: "Great, now I've done this by hand a few times, I think I can automate it reliably! Oh, oops, turned out I only had one more case of it left to do."

TERRIFIED OF RUNNING OFF THE RUNWAY: "This is a one-off, so it would be a waste of time to automate it, I'll just do it manually."
[next day] "Oh, oops, I made a mistake and have to do it again. But it should be fine this time."
[a month later] "Even though I've had to redo it 25 times already, surely _this_ is the last time? So it would still be a waste of time to automate it."

@simontatham I remember from my SPSS days, that most dialogues would offer to emit the action as commands. While they were not yet generalized, they offered a great start for later automatization at almost no additional time needed (you set up everything in the dialogue and just had to hit execute on the output command)

@TheConstructor yes, I love GUI programs that show you the underlying CLI commands the GUI actions translate into! I've used a couple as well. When I joined my current employer they used a bug tracker based on a database, whose Windows client was able to show its log of SQL commands in an extra pane. And their current flagship GUI debugger has a command-line mode too and a log window showing the CLI equivalent of each GUI action you take.

They are twice as much work to write, of course. But it's worth it.