Home > Power User >
Talking Computers AppleScript


Here's a fun example of the power of AppleScript to control multiple computers. This script allows any number of computers to have a conversation (literally!) with each other. It's been tested to work with OS X (Jaguar). I suspect it will also work in OS 9, but I had trouble making it work in a mixed (OS 9 and OS X) environment.

QuickStart: If you're new to Applescript, you'll need to copy and paste the script below into Script Editor (Located in your AppleScript folder in your Applications folder). Next, you'll need to tell each of the computers to allow remote Apple Events (in System Preferences> Sharing ). Assuming you have 4 computers (one is the controller of the other 3), all you need to do is subsitute the IP addresses (or the DNS host names) of the 3 computers that you want to use for machine1, machine2, machine3. Then run this from the fourth computer and enjoy! The first time you run the script, it will ask you to log in to each computer. You'll need to have a valid user account on each. You can store the login in your Keychain so you won't have to login during subsequent runs.

For a little more modification, you'll see there's a list of voices for each computer. You can substitute the voices here with any of the other voices you find in Speech System Preferences.

There's also a Conversation List, which contains 2 conversations, each one with a phrase for each of the 3 computers. You can add more conversations, change them, add computers, etc. I'd love to see this run in a classroom lab with 20+ computers all talking!

set theMachineList to {"eppc://machine1", "eppc://machine2", "eppc://machine3"}
set theVoiceList to {"Victoria", "Princess", "Bruce"}
set theConversationList to {{"Good Morning!", "Nice day, don't you think?", "Hi everybody"}, {"Gee, it's pretty boring around here.", "Don't you have any work to do?", "She never get's anything done."}}

repeat with i from 1 to the length of theConversationList
   set thisConversation to item i of theConversationList
   repeat with i from 1 to the length of theMachineList
       set thisMachine to item i of theMachineList
       set thisVoice to item i of theVoiceList
       set thisString to item i of thisConversation
       using terms from application "Finder"
            try
               tell application "Finder" of machine thisMachine to say thisString using thisVoice
           end try
       end using terms from
   end repeat
end
repeat