tell application "System Events"
tell (first process whose frontmost is true)
if its name = "Notes" then
set its visible to false
else
tell me to activateNotes()
end if
end tell
end tell
on activateNotes()
tell application "Notes" to activate
end activateNotes
After I posted the above, I did go back to using an AppleScript that I created before I got Keyboard Maestro:
tell application "System Events"
if not (frontmost of application "Notes") then
tell application "Notes" to activate
else
if frontmost of application "Notes" then
set visible of process "Notes" to false
end if
end if
end tell
It does work, so I have a working solution.
Thank said, does @peternlewis know why the original macro stopped working when I upgraded to Ventura?
This action seems to work fine with Notes on my test Ventura Mac, so it's hard to suggest what the issue might be.
I thought maybe Notes had moved location (like Safari did), but it doesn't seem to be the case.
Perhaps something else is related, maybe the trigger, maybe some other things happening on your Mac? Maybe your Mac just wants a restart (did you restart after the Ventura upgrade? I always recommend restarting a second time after any upgrade to ensure a properly clean system).