How can you change camera settings using AppleScript?
  • This is probably a question best answered by Ben, but I'm totally open to others' ideas. :)

    I'm trying to use AppleScript to change camera settings, but I cannot seem to get past the first hurdle, opening the Cameras Preferences. This is the code I'm trying. I see the Cameras button highlight three times. Like it was clicked three times (just like this code does) but the screen stays on the General tab. I'm trying three different/similar commands and none seem to work. I'm not sure why it won't actually click.

    Apparently Markdown is not enabled on the forum so I cannot make this look any prettier.. Copy paste it into Script Editor and hit Run. You'll see the problem.

    activate application "SecuritySpy"
    tell application "System Events"
    tell application process "SecuritySpy"
    keystroke "," using command down
    click button 2 of toolbar 1 of window 1
    perform action "AXPress" of button 2 of toolbar 1 of window 1
    tell window 1
    tell toolbar 1
    tell (first button whose name is "Cameras ")
    perform action "AXPress"
    end tell
    end tell
    end tell
    end tell
    end tell

    What I'm really trying to do is change the "script action" on every camera. As you may or may not know/remember, I have a script that integrates with Messages.app. Right now, it's a manual process setting the script action on all the cameras. I want to automate that task, but I'm now at a loss as to how.

    Thanks for the help!

  • Hi Ben,

    Thanks for the information! That method requires that I store (or at least prompt for) a user's password, not to mention username and url/port. I'm avidly trying to avoid that route. Believe me, I appreciate a well thought-out and fully-implemented API as well as the next developer. But I'm writing an application that is designed to run locally and with as little human interaction as possible. Using the API requires the user to turn on the interface, configure access, then provide that access to my installer. With all those steps, they could have just as easily set their cameras to use the applescript my installer installs.

    Is the future of AppleScript bindings in SecuritySpy not in my favor? I feel like the Library hasn't changed in years and we still have "sensitivity" and "motion" parameters available. I really can't figure out why someone would want to adjust those specific settings through AppleScript but not all the others. The ability to set the script handler from another script? Genius! Or so I thought. I also notice the active and passive commands are deprecated without replacements.

    AppleScript has it shortcomings, but the power of its IPC is unsurpassed on a Mac.

    I'm going to continue to dig into this. I really want to change these settings from a script; without a password. Thanks again!
  • Quick side thought while you're here: What is the feasibility of changing "Run script" to "Run command" to support any unix command? I'm looking into writing a Go interface to Messages.app. Moving from applescript to a compiled binary that forks immediately would be more ideal I think. I sometimes get green video when SecuritySpy interacts with Messages.app now and I'm pretty sure it's the applescript handler that's running. This would be a really nice feature and from my limited point of view, seems easy to change.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!