sjmarbu wrote:Does Indigo support Global Scripts? By that I mean an applescript that can be executed by any trigger? If so, how would such a script access state variables (applescript properties) that would be persistant and accessible from any script run within Indigo?
There are a couple of different techniques you could use for your speaker signal routing automation. I'd suggest we start by creating an AppleScript attachment script, which is a global script that Indigo will dispatch all X10 commands to automatically.
To store a global _currentSpeaker_ state you can either use an Indigo variable, which will persist across application runs and be accessible from all scripts, or you can use an AppleScript "property". In my example script below, I use an Indigo variable. To see an example of an AppleScript property in use, you can look for "currentVolume" in the _iTunes Attachment.scp_ attachment script located in your _Indigo User Data/Scripts/Attachment/_ folder.
Below is a link to a sample script I wrote that illustrates how to accomplish the mutually exclusive on states you need. It surely won't work exactly as I wrote it (I don't know what addresses your X10 switches are), but it should get you started. Take a look at it and let me know how it goes.
(6/2/2004 Update: Link to script removed. Attachment script architecture have changed a bit since version 1.0, so this script is now out-of-date.)
Note that the all attachment scripts get X10 received commands (AppleEvents) only (along with a power failure message, I believe). This means that the script will not get called, and thus will not provide any mutual exclusive behavior, if you manually turn on your X10 switches from within the main Indigo window. However, if you use a remote control, or any method that will end up causing any of your X10 interfaces to receive the command, then it will work.
Some notes on attachment scripts, such as the one above:
- They must live inside of your _user folder/Documents/Indigo User Data/Scripts/Attachments/_ folder. All attachment scripts in this folder will automatically be managed by Indigo. They will be sent AppleEvents based on X10 interface command reception, and will automatically be launched and quit in tandem with Indigo.
- They must be save as script "Applications". You should also choose the "Stay Open" and "Never Show Startup Screen" options from the script editor when initially creating the attachment file. For the adventurous -- these attachment plug-ins do not have to be AppleScripts. Any application that can receive AppleEvents can be placed into the attachments folder and will automatically be sent AppleEvents, and will automatically be launched and quit in tandem with Indigo.
sjmarbu wrote:I've tried to compile an external applescript using ScriptEditor, but since it doesn't have access to Indigo's variables, it won't compile...
To access Indigo's internal AppleScript dictionary use the following line:
using terms from application "Indigo"
sjmarbu wrote:Is there online documentation related to heavy duty applescripting with Indigo?
Is there a user manual somewhere?
Although Indigo has a built-in Apple help book, the section on AppleScript only gives a brief overview of scripting. I believe it also points to this online forum. Circular reference, ehh?
The AppleScript extensibility model (object model, dictionary, attachment model, etc.) is a work in progress. It does a great deal currently, but the key to providing all the functionality our users need will be based on requests and feedback. So you can expect to see new verbs, such as your previous Play Sound request, in future versions of Indigo. You can also expect to see more formal documentation on extensibility of Indigo in the future. In the mean time, you can use the Indigo dictionary documentation viewable from the Script Editor, the sample scripts that shipped with Indigo, and of course this forum, to help get you up and running.
Keep the good questions coming, Scot!
regards,
matt