I had tried this in macOS 14 and I knew activateIgnoringOtherApps was deprecated, but it failed there as well. I just now tried sudo -k -s in terminal, and it fails there until I quit out of that command. So this has something to do with secure input mode.