Thursday, March 05, 2009

Learning applescript: controlling skype

While I've always known that you can control many of the applications running in OSX using applescript I have very rarely tried that myself.

Now, as I have a use case of semi-automation of skype video calling for the kids I started experimenting. I did buy a tikitag rfid reader on cheap which will be used for triggering the call.

Here's what will be triggered by the rfid tag. This simple script checks if person xxxxxx is online and tries to open a call if he is. At the same time the script enlarges the call window to full screen for maximum video size. I have added some text-to speech notifications just for sake of experimenting, most probably I will replace them later with recorded samples.

Edit: Updated the script a bit and framed it in

SkypeCall("xxxxxx")

on SkypeCall(login)
set AppleScript's text item delimiters to " "
tell application "Skype"
set foo to send command "GET USER " & login & " ONLINESTATUS" script name "MyScript"
set UserStatus to my GetPart(foo, 4, " ")
if UserStatus is "ONLINE" then
say "soitan"
send command "CALL " & login script name "MyScript"
copy (run script "tell application \"Finder\" to desktop's window's bounds") to bounds of window 1
else
say "[a] onnnnissstu!"
end if
end tell
end SkypeCall

on GetPart(s, p, d)
set theList to every text item of s
return (item p of theList)
end GetPart
I used this macoshints article as an example.

1 comment:

Unknown said...

Great stuff!

I'm actually trying to solve a related problem, and think you can help. We have an emergency call line where people dial and listen to a message in case of an emergency. The problem is that the messages can be long and change during the emergency.

My idea is to take your script and use skype to leave the message. I want it to dial all the appropriate numbers (including voicemail password, using pauses), then launch an apple script to pipe speech to skype, then hang up gracefully.

Do you think this is possible. My skype account is screwed up.