Accepting commands from other AppleScript-Apps

Hi

My next project is an “alarm center”.
I have in mind a system using several apps and hardware, all of which supports applescript.

i will have two (de-/)activating methods, one via an RFID reader that triggers an applescript event via keyboard maestro.
the second is with a RF remote which is connected via a arduino that gives out a command via serial connection. the serial connection again triggers an applescript (SerialPort X from MacSoft).

these two input methods are just an on/off event.
when the alarm system is “on”, the arduino board turns on some lights at 30% with a relay so that in the room there is always a little bit of light.
at the same time, EvoCam activates the webcam and checks for motion.

as soon as motion is detected EvoCam triggers as VoIP Call with Dialectic (applescript’able VoIP) to my cell phone.
at the same time, quicktime plays an alarm sound (not too loud thou) via applescript, and the lights are turned 100% on via serial connection on the arduino.

as you see, there are in total 4 different applescript applications involved.
maybe even two more if i add bento and/or PHP backend.

well what i want to do, if possible, is a central application that handles all the different apps and connects them together.

so that any app (that supports applescript) could trigger my application like this

“tell securityCenter to set alarmState to true”
where “securityCenter” is my own app of course and alarmState is the state the alarm system is in.

so, is it somehow possible to call a function or something like that on my app via another applescriptable application?

Hi,

adding custom scriptability is quite difficult. It’s possible only in Xcode (Developer Tools).

An alternative is to load script objects and access their properties and predefined handlers

Thanks

Well, I would script the application in Applescript Studio anyway.
I just thought that this might be something about applescript in general and therefore posted it in AS/OS X.

About the option with the Objects.
I don’t understand the theoretical aspect of this.
by Object you mean something like a variable?

I mean this

Oh I see.
Well, from what i’ve read so far, this is exactly what I want :smiley: Thanks Stefan you saved my year.
I’m not finished that chapter, but I hope these also work between different applications.
Anyway thanks for pointing them out.

Couldn’t you just put two handlers in the main project: One that starts and one that stops the alarm, make your app scriptable (in the info.plist file I think) and then thru ScriptEditor, or another ASS-Application, call those handlers?

Like this:
Main Project

on AlarmClockOn()
	-- put in the right code
end AlarmClockOn

on AlarmClockOff()
	-- put in the right code
end AlarmClockOff

ScriptEditor or another ASS-App

-- Alarm Clock to ON
tell application "securityCenter"
	path for script "NameOfScriptWithOnHandler"
	load script posix file result
	tell result to AlarmClockOn()
end tell

-- Alarm Clock to OFF
tell application "securityCenter"
	path for script "NameOfScriptWithOffHandler"
	load script posix file result
	tell result to AlarmClockOff()
end tell

Hope It Works,
ief2