I have a simple macro that selects the Safari File>Share>Messages menu item. It has worked for a long time. Today, it's not working. Any idea what could be going on? I did the Safari security update last night, if that matters.
I sympathize. This is Apple's own code and it fails here on Safari 16:
Share From Safari Macro (v10.2)
Share From Safari.kmmacros (2.0 KB)
Apple have broken it. As @mrpasini says,
tell application "System Events"
tell process "Safari"
every menu item of menu of menu item "Share" of menu "File" of menu bar 1
end tell
end tell
...should return
{{menu item "Email This Page" of menu "Share" of menu item "Share" of menu "File" of menu bar item "File" of menu bar 1 of application process "Safari" of application "System Events",...}}
...but now gets
{{}}
But you can spoof "new" Safari with
tell application "System Events"
tell process "Safari"
set frontmost to true
click menu "File" of menu bar 1
click menu item "Share" of menu "File" of menu bar 1
every menu item of menu of menu item "Share" of menu "File" of menu bar 1
end tell
end tell
...and get
{{menu item "Email This Page" of menu "Share" of menu item "Share" of menu "File" of menu bar item "File" of menu bar 1 of application process "Safari" of application "System Events",...}}
That suggests you could double your macro action -- have the first click "File"->"Share" to populate the "Share" menu, and the second can then click "File"->"Share"->"Messages".
You may even have to triple it and do "File", then "File"->"Share", then "File"->"Share"->"Messages". Suck it and see!
If all else fails, an "Execute AppleScript" action with the following AS should work:
tell application "System Events"
tell process "Safari"
set frontmost to true
click menu "File" of menu bar 1
click menu item "Share" of menu "File" of menu bar 1
click menu item "Messages" of menu of menu item "Share" of menu "File" of menu bar 1
end tell
end tell
Oh, Apple ... Nice_S, yes this AppleScript does work. Thank you!
Hey Sherman,
See this:
macOS 12.6 breaks 'Select or Show a Menu Item'? - #3 by ccstone
It it works it should be faster than AppleScript.
-Chris