Block Sender in Apple Mail

I just installed Keyboard Maestro, so I could create a keyboard shortcut for Block Sender and Delete in Apple Mail. Am I on the right track? (see screenshot below).

I emailed support, and Peter said this:
It looks like Block Sender / Block Contact is only available in the contextual menu.

So if the email message is selected, you can use the sequence:

Type a Keystroke action (https://wiki.keyboardmaestro.com/action/Type_a_Keystroke) Control-Return (opens the contextual menu)
(may need a very short Pause action (https://wiki.keyboardmaestro.com/action/Pause) here to allow the menu to appear)
Insert Text by Typing action (https://wiki.keyboardmaestro.com/action/Insert_Text_by_Typing) "Block"
Type a Keystroke Return (select the menu)

But the message will need to be selected first. That looks unavoidable.

Do you have a specific question based on Peter's reply? Everything he said is true—you need to select the message first in order to get to the contextual menu.

-rob.

Hi Rob,

Thanks for your reply. Keyboard Maestro is very confusing. I watched the video, but I still don’t understand it. I tried to follow Peter’s instructions and set up the Macros, but I think I am missing something. When I run the Macros, click on a message, and click, “control return”, it does not block the sender. I would pay someone to do a screen sharing with me to help me set it up if anyone is willing.

You have configured your macro with a Hot Key trigger of Control-Return.

My instructions were to use the Type a Keystroke action to type Control-Return, which modern systems take to mean "activate the contextual menu on the selection".

Almost, but you've used ⌃Return as the macro trigger when you should be simulating that keystroke so the OS acts on it.

Here I've used ⌃B as the hot key trigger (the keyboard shortcut to run the macro). And it's good to start with longer Pauses so you can see the macro in operation -- once you know it works as you want you can try shorter Pauses to speed things up.

1 Like

Thank you! It’s now working perfectly. I also added Delete.

1 Like

Excellent!

A word of caution about your selected hot key trigger, though. ⌘. is the global "Cancel" command and you can use it to "press" the "Cancel" button in dialogs, stop a web page from loading, and abort many operations in particular apps. If you use it as your hot key here then, because "Block Sender" is in your Global Macro Group and available everywhere, you won't be able to use ⌘. normally anywhere -- it will always trigger your macro, and if you forget that you may have some unexpected keystrokes and, particularly, deletions going on.

It's worth taking a moment to look at the macro more closely.

The macro is run when it is "triggered" -- in this case that's "when hot key combo ⌘. is pressed", and you'll find many more triggers on the "Triggers" Wiki page.

When the macro runs it works sequentially through what you see in the Editor, from top to bottom:

  1. Simulate pressing ⌃Return on the keyboard
  2. Pause for 0.2s
  3. Type "block"
  4. Pause for 0.2s
    etc

And that shows how you develop your next macro:

  1. Decide what you want to do
  2. Run through the process manually a couple of times while making a note of every key pressed, every menu item selected, every decision you make -- and, importantly, any assumptions (here we've assumed that "Mail is the active application and one or more emails are selected")
  3. Translate each step into KM by looking for Actions that do what you want and Tokens and Functions that get the data you need (maybe the subject of an email, the current date, the number of lines in some text)
  4. Test your macro, refine your plan, change the Actions etc, test again until it works how you want it to

That's not all there is to KM, not by a long shot, but it will form the basics of almost every macro you'll make.

And if you ever find yourself stuck for more than a few minutes -- post a question to the Forum! Never think a question is too simple to ask, we were all where you are now when we started so understand how confusing it can be.

Thank you for pointing that out. Is there a way to have the hotkey only work in Mail?

1 Like

Groups are the answer.

Basically, create a new group (call it Mail Rules or whatever you like), and set it to only be available in Mail; here's how mine is set up:

Then move your Mail-only macros to that group.

-rob.

2 Likes

Thank you!