You can automate more than you think
(Sorry this is late! Dealing with COVID.)
I have mild ADHD. I can focus on strenuous mental tasks, but I can't handle boring or repetitive work. Even something like "manually navigating to a folder" is enough to make procrastinate. I'm always looking for ways to aggressively optimize my workflow.
For example, one thing I have to do a lot is type my address into emails and chats and the like. For most people that isn't a big deal, but for me it's disruptive. One tool I use, AutoHotKey,1 has "hotstrings": if you type a hotstring, it replaces the text with a substitute.
::;adr::{My address}
Instead of 50 keystrokes, I can just type ;adr
, and AHK will put in my full address. That's seven whole seconds saved! According to the notorious xkcd efficiency chart, this might even add up to two whole hours saved across five years. That's an efficiency gain of 0.007%!
But I didn't automate that to save time, I automated it to save focus. I need to think to write out my whole address. I don't need to think at all to type ;adr
. I don't need to burn any of my limited focus on something menial anymore. It matters even more when automating something I don't know by heart, like my Zoom URL or my EIN. Then it takes focus to find it and then copy it over.
GUI Automation
A lot of the stuff we do with GUI apps is really repetitive. They're not designed for programmatic scripting because supporting that is hard and everybody has slightly different repetitive needs they need to automate. But if an app supports keyboard shortcuts and mouse clicks, that's our Trojan horse for GUI-scripting.
Often when I'm researching something, I need to know when something was added to a website. Easiest way to do that is to look through Internet Archive snapshots and first the earliest date it appears. That's a repetitive task: copy the website url, open archive.org, click the Wayback machine searchbox, paste the url, and hit enter. Again, not difficult, but inconvenient, enough to make me regularly Not Bother with checking the archives.
This is easily scriptable once you notice two things:
- The wayback machine urls are fixed. The archives for
example.org
ishttps://web.archive.org/web/*/https://www.example.org
. - In Firefox,
ctrl+L
selects the URL.
So I wrote an AHK script to reopen a page in the archive.
>!^a::
Keywait, RControl
Keywait, RAlt
SendEvent, ^l
SendInput, {left}https://web.archive.org/web/*/{enter}
return
Some GUIs are harder to target, but there's usually some trick you can use to build your automation. You can also write scripts that cross applications. Twitter occasionally eats a tweetstorm I'm writing, so I now write them in vim and copy them over. That's super annoying to do, though, so it's on my list of things to automate. Vim is super easy to drive with a scripting engine, since everything is keyboard-centric already.
Speaking of Vim...
I'll admit: I've never been a fan of vim golfing. That's where you try to do a transformation in as few character strokes as possible. While it's an obvious extension of the vim spirit, it goes against why I automate: to do things in as little thought as possible.
If you look at a vim golf site, people pull obscure features and commands to save a character or two. That takes a lot of thinking that gets in the way of muscle memory. I rely much more on the "impure" features of vim, the kind that gets the smug vim weenies calling you an Emacs fanboi. You know, plugins and functions and stuff. Here's something I've got for dropping markdown fenced code blocks into things:
function! s:CodeSnippet(...)
let out = '```'
if a:0 == 1
let out = out . a:1
endif
" ↓ makes it easier to %s OPENING set of code fences
put = ' '.out
" ↓ outputs clipboard
put +
put ='```'
endfunction
And here's one I added for Hugo shortcode blocks:
function! s:ShortCodeBlock(name)
let s:sc = split(a:name)[0]
put ='% '</span>.<span style="color: #66d9ef">a</span>:name.<span style="color: #e6db74">' %'
put ='% /'</span>.s:<span style="color: #f8f8f2">sc</span>.<span style="color: #e6db74">' %'
endfunction
These don't save a whole lot of time, but writing all those special characters is really annoying and makes my ADHD flare up, so it makes sense to automate them away.
Something more traditional
I also heavily use shell scripts (Powershell, in my case) to automate lots of small processes in my work. I have a script that compiles my workshop materials into a single zip and then another that uploads the zip (along with a supplementary site) to s3. I also have a deploy script for my website that makes sure I don't have empty links or editor marks in my public posts:
$Content = Get-ChildItem -Path content\post,content\page,content\talks -Include *.md -Recurse -Force |
Where-Object { -not (Select-String $_ -Pattern "draft:") }
$Unfinished = Select-String $Content -Pattern "TK" -CaseSensitive
if ($Unfinished) {
Write-Output "Some posts are unfinished:"
Write-Output $Unfinished
exit
}
$EmptyLink = Select-String $Content -Pattern "]\(\)" -CaseSensitive
if ($EmptyLink) {
Write-Output "Missing a link:"
Write-Output $EmptyLink
exit
}
# Rest of build script follows
A terrible idea
At a previous job we used Selenium to do end-to-end browser tests. Then we had to integrate with a client who didn't have a complete API; we had to manually click buttons in their administration webpage. So I turned Selenium around and used it to click the buttons in production. Manually forced in an API.
During that, I learned you could manually control the browser at the same time as Selenium. That made debugging really easy, since I could manually click around in the browser and then run commands in the Ruby REPL. That got me thinking: there's no reason you couldn't use a selenium instance as your daily browser. 99% of the time you'd treat it like a normal Firefox browser, but you could also run scripts to control it. This would be more powerful than injecting javascript as you could automate across tabs and pages. I've never tried it out in practice, though.
-
AutoHotKey is Windows-only, but there's a similar tool called Hammerspoon for Mac. ↩
If you're reading this on the web, you can subscribe here. Updates are once a week. My main website is here.