I want to block a person in the Messages application and then delete the message. As Messages has no applescript command to block a person, I wrote a GUI script to identify the menu Block Person. Although this script prompts the dialog to block a person, I am not sure how to click the appropriate “Block” button in that dialog, to complete the task.
tell application "Messages"
activate
end tell
tell application "System Events"
tell process "Messages"
set targetMenu to first menu of menu bar 1 whose name contains "Conversation"
tell targetMenu
click (first UI element whose name contains "Block Person…")
end tell
end tell
end tell
If you know of a non GUI AppleScript method that can block a person, I would learning about it to circumvent any graphic use interface, altogether.