Skip to content

Instantly share code, notes, and snippets.

@AkdM
Last active November 25, 2022 01:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkdM/dcad6ef973c1d4574af803a9a214c6f5 to your computer and use it in GitHub Desktop.
Save AkdM/dcad6ef973c1d4574af803a9a214c6f5 to your computer and use it in GitHub Desktop.
Generate new "Hide My Email" email with iCloud+ using AppleScript
-- Kill System Preferences first if already open
if application "System Preferences" is running then
tell application "System Events"
set theID to unix id of processes whose name is "System Preferences"
try
do shell script "kill -9 " & theID
delay 0.1
end try
end tell
end if
try
tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preferences.AppleIDPrefPane"
tell application "System Events"
repeat until window "Apple ID" of application process "System Preferences" exists
end repeat
set theWindow to window "Apple ID" of application process "System Preferences"
-- Select iCloud
repeat until row 6 of table 1 of scroll area 1 of theWindow exists
end repeat
select row 6 of table 1 of scroll area 1 of theWindow
-- Right part of the window
set rowDetails to group 1 of theWindow
repeat until row 4 of table 1 of scroll area 1 of rowDetails
end repeat
-- Select the "Hide my Email" row
set hideMyEmailRow to row 4 of table 1 of scroll area 1 of rowDetails
repeat until button of UI element 1 of hideMyEmailRow exists
end repeat
click button of UI element 1 of hideMyEmailRow
log "Clicked at: " & (value of static text 1 of UI element 1 of hideMyEmailRow)
-- New opened window, which is a sheet
set hideMyEmailSheet to sheet 1 of theWindow
-- Wait for the busy indicator to appear
repeat until busy indicator 1 of hideMyEmailSheet exists
end repeat
-- Then wait for it to disappear
repeat until (not (busy indicator 1 of hideMyEmailSheet exists))
end repeat
set sheet1 to sheet 1 of theWindow
set addButton to button 1 of group 3 of group 1 of group 1 of UI element 1 of scroll area 1 of sheet1
click addButton
end tell
log "End"
end tell
on error errMsg
log "ERR: " & errMsg
end try
@dcm
Copy link

dcm commented Oct 10, 2022

@DeepHeat01 that did it, thanks!

@AkdM
Copy link
Author

AkdM commented Nov 25, 2022

Oops, I didn't see those notifications. Sorry!
I will maybe try to make something more like an app, since AppleScript isn't very practical for this usage. But Apple is limiting almost everything on this side unfortunately 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment