4

I have made an apple script that takes pictures of people using PhotoBooth. However, every time I open it, it asks for permission to use PhotoBooth instead of instantly taking a photo. I have already set the [Security & Privacy > Privacy > Automation > Allow Script to use PhotoBooth] but it still prompts me every time to allow PhotoBooth. Is there any way to fix this without downloading anything or changing my script? Thanks!

yuwe
  • 167
  • 1
  • 13
  • how did you set [Security & Privacy > Privacy > Automation > Allow Script to use PhotoBooth] ? I am working in an app, which uses, appleScript, but it doesn't work in Mojave. its not a sandboxed app, & i have also added "NSAppleEventsUsageDescription" in .plist file, but still i am not able to get the permission popup itself. – Krishna Maru May 01 '19 at 11:54

1 Answers1

4

Is your script saved as an applet? While 10.14 remembers previous user-granted permissions, it will re-prompt every time the script changes. Traditional AppleScript applets implement a basic persistence mechanism that saves the current state of the script's top-level variables upon quitting. Discussion here:

https://forum.latenightsw.com/t/mojave-and-applescript-applets/1563/13

One quick trick for avoiding any persistent state:

script MyScript
    -- original code goes here…
end script

on run
    local tempScript
    copy MyScript to tempScript
    run tempScript
end run

If you do need to save state (e.g. user preferences) between runs, then you'll either need to code sign the applet or else use an alternate mechanism (e.g. NSUserDefaults via AppleScript-ObjC).

foo
  • 254
  • 2
  • 3
  • Thank you so much! Worked first try. I didn't need any save states so the code worked first try :) – yuwe Oct 13 '18 at 22:43