The Load Images button in Apple Mail on Mac OS X doesn’t have a keyboard shortcut, and there’s no easy way to add one. This is very annoying. This article shows how to add one, using AppleScript and FastScripts.
I like Apple Mail for Mac OS X, but one thing that irritates me to no end is that the Load Images button (Load Remote Content in Mac OS X 10.10), which loads the images in a message on-demand, doesn’t have a keyboard shortcut. Because it’s not a menu item, there’s no easy way to add one. I looked for a way to add a keystroke to Load Images for more than five years before I finally found a way to do it.
The hard part is triggering the Load Images button itself, by anything besides a mouse click. What finally did it was using the GUI Scripting feature of AppleScript to tell the button to click itself. Once I had an AppleScript that worked, it was simple to use FastScripts to trigger the script with a keyboard shortcut.
Why don’t I let Mail load images automatically? Spammers use image loading to confirm the validity of an email address. See this Apple Support Forum post for some details, and how to turn it off.
AppleScript to Load Images in Apple Mail
Download the Load Images script v1.11, 2021-12-14
The work of the script can be done by a single line that might look like this:
click button "Load Images" of
UI element 1 of row 1 of table 1 of scroll area 1 of front window
(Because Mail.app’s user interface has changed across various versions, and with different preference settings, the actual code is more complex. See the AppleScript for the full, ugly details.)
This user interface elements path, or specifier, tells the GUI Scripting system how to reach a specific user interface element, in this case a button, and what to do with it. It’s far from obvious how to determine one of these UI specifiers just by looking at a Mail window; I used the very interesting developer tool UI Browser to figure it out.
It’s also specific enough to be brittle; it has changed from prior versions of Apple Mail, and will probably change in the future. When it does this script will stop working and start beeping. I’ve written the script to adapt to a few different version and configuration possibilities, and I’ll try to update it if it ever breaks. The current version (v1.6) is compatible with Mac OS X 10.5 (“Tiger”) through Mac OS X 10.10 (“Yosemite”).
The rest of the script is error handling and AppleScript ceremony. It should make sense if you’re familiar with AppleScript, and there are plenty of comments, so I won’t describe it here.
Add a Keyboard Shortcut for Running the AppleScript
Adding a keyboard shortcut for an already-existing menu item is easily done using the Keyboard preference pane. Adding a keyboard shortcut for an AppleScript requires a third-party utility. You might already have a favorite–there are lots to choose from–and so do I. FastScripts from Red Sweater Software does a great job handling application-specific AppleScripts, and it’s free if you don’t need more than 10 keyboard shortcuts. (It’s also a good value at $14.95 for the unlimited version.)
Create the shortcut for the AppleScript
- Install and run FastScripts, and then switch to Mail.app.
- From the FastScripts menu, choose Open Mail Scripts folder.
- Move or copy the Load Images script into the Mail Scripts folder.
- From the FastScripts menu, choose Preferences…, click the Script Shortcuts tab, and add your preferred keyboard shortcut.
Note: If you use the same keyboard shortcut I did, Command-Shift-L, you’ll need to change the keyboard shortcut for the existing menu command that uses it, by adding a new one to that command, using the technique at the Mactuts+ article linked above.