Local network messaging using AppleScript

Feb 15, '05 10:14:00AM

Contributed by: d.

As an office manager I was looking for a way to send my co-workers little messages over the network without using Mail or IM – without using any app for that matter. OS 9 did something like that using the built-in Sharing control panel (easter egg?), but OS X had nothing like that. Inspired by the Remote Apple Events hint, I wrote this script:

tell application "Finder"
  display dialog "Choose computer:" buttons ¬
    {"Workstation_1", "Workstation_2"} default button 2
  if the button returned of the result is "Workstation_1" then
    set machine_chosen to "eppc://Workstation_1:password@192.168.1.45"
  else
    set machine_chosen to "eppc://Workstation_2:password@192.168.1.46"
  end if
  display dialog "" default answer "How are you doing?" buttons ¬
    {"Cancel", "Send"} default button 2
  copy the result as list to {text_returned, button_pressed}
end tell

tell application "Finder" of machine machine_chosen
  activate
  beep
  display dialog text_returned buttons {"Cancel", "OK"} ¬
    default button 2 giving up after 30
  set the clipboard to the text_returned
end tell
To make this AppleScript work, activate Remote Apple Events in the Sharing preference pane on the machine you want to send a message to. Change the machine names, passwords, and IP's, save the script in the Scripts folder of your own machine, and send your message. The set the clipboard to the text_returned line I added to let the receiver use the text I send them, if they wish. They then paste the text anywhere they want.

Just to be secure: make sure your network security settings won't allow events from unknown IP numbers, and turn on the Firewall.

Comments (21)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2005021010302911