Problems with iMessage AppleScript
  • I'm new to SecSpy, and although somewhat technically able, not a coder by trade.

    I've been trying to get SecSpy to send iMessages when triggered by motion by using the Prefs/Cameras/"MyCam"/Actions/Run Script/ function, and using the AppleScript provided by Bensoftware site at Applescript Examples. (

    I have been able to get it work, so I know that my editing of the script (changing Cam # and buddy phone number or email send to name) does not break anything, and I do get an image from the camera calling the script.

    However, I seem to be having a problem with the "version" of the temp file that is sent. That is, if the script is triggered, it doesn't send the image it just grabbed, but instead it sends the image that it grabbed one trigger before. Example:

    Trigger 1: timestamped @ 12:00 - sent correctly
    Trigger 2: timestamped @ 12:01 - image with 12:00 stamped sent (again)
    Trigger 3: timestamped @ 12:02 - image with 12:01 stamped sent
    Trigger 4: timestamped @ 12:03 - image with 12:02 stamped sent - etc

    So I'm wondering if:
    a) is anyone else having this same problem?
    b) is there an edit that can be made to the script that would essentially flush the image that was just sent?
    c) is there another (simple) way to get immediate notifications on my mobile device since emails are not pushed instantly?

    Thanks in advance for any insight on the issue.
  • I think I found a solve for this problem.

    It seemed like the script was sending the tmp file before it had a chance to write the new one. So I added the following tell between the capture tell and the send tell:

    tell application "System Events"
    delay 1
    end tell

    I've never coded AppleScript, so maybe System Events is the wrong app to tell, but it seems to have solved the problem, albeit adding 1 second to the sending of the iMessage.
  • delay doesn't need to be in a "tell" "end tell" - it can be on its own between other code that does things.
    you can delay fractions of a second as well, so you might be able to do a 0.5 instead of 1 if that is enough to also work around the problem - I believe it is tenths of a second is the smallest fraction so 0.1 would be the smallest possible.
  • Thanks BrianM! I'll update accordingly.

Howdy, Stranger!

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