Get URL for selected message with AppleScript and TextExpander

I often use message://<[email protected]> URLs to reference a specific email in OmniFocus or Evernote: clicking one of these URLs will automatically open up the source message in

There's not a great way to get these very handy message URLs without AppleScript, so based on this SuperUser answer, I created a TextExpander snippet.

Now, when I type xmsg, TextExpander will insert the message URL for the selected message in into whatever application I'm working in.

Here's the TextExpander snippet, and here's the AppleScript:

tell application "Mail"
	set selectedMessages to selection
	set theMessage to item 1 of selectedMessages
	set messageid to message id of theMessage
	-- Make URL (must use URL-encoded values for "<" and ">")
	set urlText to "message://" & "%3c" & messageid & "%3e"
	return urlText
end tell

Safely getting a MD5 checksum for a file

There are lots of 3rd party utilities out there for getting the a checksum of a file, but with sensitive data it's best to not read your files into any untrusted application.

Here is how to get MD5 checksums using only 1st party functionality from the OS vendor (Apple or Microsoft).


Download, which is a thin wrapper around the built-in md5 command line utility (based on this AppleScript). If you run, it will ask you to pick a file to checksum. If you drag a file onto, it will checksum that file immediately.

You can verify the (very short) code for this application by opening AppleScript, going to File > Open, and selecting

You can also run md5 /path/to/file.txt in


Of course, this is not nearly as easy on Windows.

  1. Go to this Microsoft knowledge base page and click the download link for the File Checksum Integrity Verifier utility package midway down the page.
  2. Run the downloaded file, agree to the terms, and select your Desktop as the location to extract the files to.
  3. Two files will be extracted: ReadMe.txt (delete this) and fciv.exe. Create a folder for this at c:\Users\yourusername\fciv\ and move fciv.exe to this folder.
  4. Go to Start > Run, type "cmd", and press Enter to open the command prompt. You should already be in c:\Users\yourusername. Type "fciv\fciv.exe -add c:\path\to\file\to\checksum.txt"

Windows – Update (2019-08-26)

You can also use PowerShell to do this:

CertUtil -hashfile yourFileName MD5


OmniFocus 2: Quick defer + due date entry with TextExpander

In OmniFocus 2, there is not a good way to quickly enter a defer date and then a due date: it involves tabbing a bunch of times or using the mouse to move between fields.

TextExpander to the rescue!

I use the following snippets to set the same defer + due date for tasks:

  • Tomorrow at 9am: xx1 → tomorrow 9am%key:tab%%key:tab%%key:tab%%key:tab%tomorrow 9am%key:enter%
  • +2 days at 9am: xx1 → 2 days 9am%key:tab%%key:tab%%key:tab%%key:tab%2 days 9am%key:enter%
  • Next Monday at 9am: xxmon → Monday 9am%key:tab%%key:tab%%key:tab%%key:tab%Monday 9am%key:enter%
  • Next Saturday 9am: xxsat → Saturday 9am%key:tab%%key:tab%%key:tab%%key:tab%Saturday 9am%key:enter%

I also have "x1", "x2", "xmon", and "xsat" set up to work in the quick entry box, which requires a few less tabs.

You can grab all these snippets here.


Ken Case of The Omni Group explains that users will only have to press tab four times if they have the "All controls" checked in the Full Keyboard Access portion of System Preferences > Keyboard Preferences > Shortcuts. I always have this turned on, like many users, so I can tab between form controls.

So if you don't have this enabled, you'll need to adjust the number of tabs in the TextExpander snippets. I still think this idea is useful for quickly setting defer+due dates if you often use the same sets of dates, even if the fields are only one tab away.

OS X: Set the output device for sound effects with AppleScript

When I switch audio output devices from LaunchBar, sometimes Mavericks decides to change my system sound effects to my laptop's internal speakers rather than the selected audio device, which is what I always want.

The command line utility I use to switch audio output sources doesn't support changing the sound effects output device, so I threw together an AppleScript. The AppleScript has to pull up the Sound panel in System Preferences on the screen, so it takes a second to run, but it's still way faster than doing it manually.

FastMail: Hide unread count for folder with a Userscript

I just wrote a JavaScript snippet to hide the unread count on folders in the FastMail web interface's sidebar. I use this with's Userscript support.

Here's the snippet:

window.mmHide = function() {
    jQuery('.FolderTree span:contains("Folder 1 name here") + .badge').hide();
    jQuery('.FolderTree span:contains("Folder 2 name here") + .badge').hide();
    // Duplicate previous line as needed

jQuery(function() {
    setTimeout(window.mmHide, 1000);
    setInterval(window.mmHide, 10000);

You'll need to also include jQuery as a Userscript. (You can just copy/paste the minified jQuery above this snippet in your Userscript.) I'm sure there's a non-jQuery way to do this but I already have jQuery available so this was easiest.

OS X: Quickly switching audio output devices

The first step is getting AudioSwitcher. This involves downloading the Xcode project at the previous link and building to get an AudioSwitcher binary. I discovered Dr. Drang keeps a bin/ directory in Dropbox, so that's what I'm doing as well. This means that I now have the AudioSwitcher binary in ~/Dropbox/bin/, and this folder is in my $PATH.

If you've done this correctly, you should be able to run AudioSwitcher -a and see a list of devices:

$ AudioSwitcher -a
Built-in Microphone (input)
Monitor Webcam (input)
Built-in Output (output)
FiiO USB DAC-E10 (output)

Now, set up some AppleScripts to run AudioSwitcher commands. For example, to switch to my DAC, all you need is:

do shell script "/Users/max/Dropbox/bin/AudioSwitcher -s 'FiiO USB DAC-E10'"

I used the AppleScript Editor and saved the script as an application in /Applications so I can trigger it quickly with LaunchBar.

(If you trust me, you can download a compiled version of AudioSwitcher here. The standard disclaimer applies, and you really shouldn't be running software from random people on the internet.)