Random ramblings about Mac, Python, TeX, programming, and more  |     |          |     |  


Microsoft Outlook: download pictures

February 12, 2020  |  tools, programming, macos

I am currently on my Mac using the Microsoft Outlook application for email. For a lot of reasons, I have turned off automatically download pictures from the Internet (see Preferences→Reading→Security). But sometimes, I want to see the pictures included in the email message I am reading. I can push the button Download pictures to see them. However, I prefer to use the keyboard. I have not found a keyboard shortcut for this in Microsoft Outlook, but since I am a programmer I should be able to program it. As usual when when I try to automate such processes on a Mac, AppleScript and Automator are the obvious tools. Usually it is easy to programatically click a button with AppleScript. However, this time I have spent too much time with Script Debugger to not find the correct element to click from AppleScript. In the end I gave up and I decided to use the position of the button. I measured (using macOS built in screenshot feature) that the middle of the button is approximately 60px from the right edge and 255px from the top of the Outlook window (even when the window is resized).

The trick is to create a Quick Action Automator workflow (previously called a Services Automator workflow) and connect it to a key binding. This is the AppleScript code in the workflow:

tell application "System Events" to tell process "Microsoft Outlook"
  set frontmost to true

  -- Position and width
  set {x, y} to position of window 1
  set {w, h} to size of window 1

  -- Approx position of button "Download pictures"
  click at {x + w - 60, y + 255}

end tell

This is how you create the Quick Action in Automator (save it as «Outlook click Download pictures»):

Outlook download pictures quick action

Finally, I register it with the same keyboard shortcut that I used in Airmail, J (in System Preferences→Keyboard→Shortcuts→Services):

Outlook download pictures keyboard shortcut

Last updated: February 12, 2020