Jump to content

Create new iCloud hide my mail address trough Alfred

Recommended Posts

Hello Alfred community,


i created a new workflow, so its easier to generate new iCloud hide my mail addresses directly trough Alfred. Most of the time you get the native prompt from MacOS if you set your cursor into an input type field "mail" if its marked correctly, but it happens pretty often that the native prompt does not pop up. If you still want to use an iCloud+ hide my mail address, you have to click up to 8-10 times trough the settings to generate and copy a new one, so i automated it with an applescript file & Alfred.


The source, more detailed information and an showcase how it looks like, can be found in the GitHub repository: https://github.com/Klizzy/alfred-hide-my-mail


Im happy to get some feedback, because that's my first workflow, which i released to the public and it would be great to be also included in the Alfred Gallery.  All my previous workflows were only for niche and for private use.


Key information extracted from the readme



1. Open Alfred (default shortcut: `Option + Space`).
2. Type `hide` followed by the label you want to assign to the new iCloud Hide My Mail address.
3. Press `Enter`.
4. Press `CMD + V` to paste the generated iCloud Hide My Mail address.

Alfred config 



Workflow screenshot



Thanks a lot!

Link to comment

Welcome @Klizzy,


Nice first submission!


My first suggestion would be to replace the config. It’s currently a Text Field but it should be a Popup Selection because you only want users to select from a few pre-defined sources. Also, adding a user-configurable keyword.

The second suggestion, and this one is trickier, is handling latency. I also have something like this locally (though I only need the panel, not the auto-creation) but the way I do it is language-agnostic because I’m clicking on elements by index instead of by name. The tradeoff is that if Apple changes the position of anything in a later macOS version, it will need a fix. Neither solution is better, just a choice. But I digress, the point is that all those GUI interactions take a while to execute. And Hide My Mail is slow. I tried your workflow a couple of times and it didn’t quite reach the end as the delays weren’t enough. In general, relying on fixed wait times for some GUI thing to finish is error-prone. My suggestion is to identify the click target, loop a short delay until it is available, and only then try to click it.

Link to comment

Hello @vitor,


thanks for the fast and valuable feedback!

The suggested Alfred settings will definitely increase the user experience and reduce the options for not supported settings.


The development of the Applescript was definitely the hardest part for me, because the official documentation and many example resources are pretty outdated. For debugging and development purposes i tried UI Browser, Keyboard Maestro, Accessibility selector and some UI debugging applescripts which i found online. UI Browser was pretty useful for debugging the general MacOS UI, but it seems that the iCloud+ Hide My Mail window differs in terms of structure, because UI Browser did not supported it.


In my initial approach i tried to identify the UI elements by their IDs, so no language configuration has to be set anymore, but i could simply not locate them with the tools which i found online. Do you have any recommendations for debugging or developing with applescript? My use case is pretty simple, because it only clicks on a couple buttons, but without a proper IDE or debugger it feels pretty clunky.


Im a software engineer myself, but its the first time i have dipped my toes into applescript, so any tips a better developer experience are appreciated.


It would be great if you could provide additional information regarding the failed workflow in your tests:

  • Did the workflow successfully generated a new mail, or did it failed already beforehand?
  • What MacOS version and device / chip did you use?
    • e.g Macbook Pro 2023, M2 Max
Link to comment
On 6/8/2024 at 2:46 AM, Klizzy said:

because the official documentation and many example resources are pretty outdated.


Tell me about it!


On 6/8/2024 at 2:46 AM, Klizzy said:

Do you have any recommendations for debugging or developing with applescript?


Not exactly. I just painstakingly learned about it over years and developed a style focused on consistency and correctness (as much as that can be achieved) and leveraging the Objective-C bridge a lot to avoid quirks of the language and enhance what it can do. That involves another rabbit hole on its own, learning to properly read Apple’s API docs and understanding the logic of the conversion to JXA.


But I can show you what I use and answer specific questions. It’s JXA (JavaScript for Automation, part of the AppleScript family).



function launchSettingsPane(pane) {
  const url = $.NSURL.URLWithString("x-apple.systempreferences:" + pane)


const hideMyEmailButton = Application("System Events")
  .byName("System Settings")

for (let retries = 0; retries < 50; retries++) {

  try {
  } catch {}


The loop is a workaround to try to press the button only after it’s available, as soon as possible, while still aborting if it takes too long.


To get the exact button, I got to the exact pane and did (note the last method: entireContents()):


Application("System Events")
  .applicationProcesses.byName("System Settings")


Then waded through that with some deduction and trial and error. Try searching for button and add click() to one of them once in a while to find your “position” in the array of options.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...