I had to write a script to automatically start iChat at login and start a video chat with a specified screenname. I wanted to only start the chat if the user was online and available, and quit iChat on an error or if the chat ended. So here’s the script I have:
using terms from application "iChat" tell application "iChat" activate log in delay 5 set theBuddy to buddy "ScreennameGoesHere" of service "AIM" try set theStatus to status of theBuddy on error errmesg number errno set message to display dialog "The user is currently unavailable." buttons {"OK"} quit return end try if theStatus is available then set theCapabilities to get capabilities of theBuddy if (theCapabilities contains multiperson video) then send "A user is attempting to contact you." to theBuddy delay 2 tell service "AIM" to make video chat with properties {participants:theBuddy} set theChat to result delay 30 try set theStatus to the av connection status of theChat on error errmesg number errno quit return end try repeat while theStatus is not ended delay 5 try set theStatus to the av connection status of theChat on error errmesg number errno quit return end try end repeat quit return else set message to display dialog "The user cannot video chat at this time. Please try again later." buttons {"OK"} quit return end if else set message to display dialog "The user is currently unavailable." buttons {"OK"} quit return end if end tell end using terms from
A couple of gotchas:
- I tried using
video chat
instead ofmultiperson video
, but that always returned false. I don’t know why. - Once the video chat has ended, you can’t poll its status (hence the
try
block).