“AppleScript is one of the crown jewels of macOS, but recent versions and policies actively prevent people from using it.”

Link. AppleScript is dying. I have not had success with any of Apple’s automation solutions. There have always been gaps I couldn’t close.