Home
Corey's Sony Ericsson Clicker Scripts
Below are some AppleScripts that I created for use with Sony Ericsson Clicker. Feel free to use them by right clicking the script icon or the script name and selecting "Download to Disk" (or whatever your browser says when it means download the link as a file), or by copying and pasting into the "Action Editor" within the Sony Ericsson Clicker preference pane.
Speak Unread Messages
This script will check the messages in all of your accounts' inboxes and speak the total number of unread messages. This script is useful for the proximity sensor!

global currUnread
global checkMailDelay

(*
Set the delay to an acceptable value for Mail.app
to check for new mail for all accounts.
Default is 15 seconds
*)
set checkMailDelay to 15
set currUnread to 0
tell application "Mail"
  check for new mail
  delay checkMailDelay
  set everyAccount to every account
  repeat with eachAccount in everyAccount
    set everyMailbox to every mailbox of eachAccount
    repeat with eachMailbox in everyMailbox
      if name of eachMailbox is "Inbox" then
        set unreadCount to unread count of eachMailbox
      end if
    end repeat
    set currUnread to (currUnread + unreadCount)
  end repeat
  (*
  I put the half second delay around the spoken number
  of messages so that it is understandable...some of the synthesized
  voices tend to string the words together too fast.
*)
  say "There are "
  delay 0.5
  say (currUnread as string)
  delay 0.5
  say "messages waiting for you."
  quit
end tell

tell application "SEC Helper"
  show screen message currUnread + " Unread Messages"
end tell

Popup Unread Messages
This script will check the messages in all of your accounts' inboxes and display the total number of unread messages in a popup window on yourr T68i. (Actually I got the idea from Eric Carroll's site, but he apparently used my script as a basis so I'm taking partial credit. Plus I changed it from a message box to a T68i popup alert.)

global currUnread
global checkMailDelay
global popupMsg

set checkMailDelay to 10
set currUnread to 0
tell application "Mail"
  check for new mail
  delay checkMailDelay
  set everyAccount to every account
  repeat with eachAccount in everyAccount
    set everyMailbox to every mailbox of eachAccount
    repeat with eachMailbox in everyMailbox
      if name of eachMailbox is "Inbox" then
        set unreadCount to unread count of eachMailbox
      end if
    end repeat
    set currUnread to (currUnread + unreadCount)
  end repeat
  set popupMsg to currUnread & " New Emails" as string
end tell

try
  tell application "SEC Helper"
    enter popup mode text popupMsg
  end tell
on error
  beep
end try

Say Something
This script will allow you to enter text in a text field on your phone, and have the computer speak the text. Great for messing with your guests!

try
  tell application "SEC Helper"
    enter text field mode title "Speak Phrase" prompt "What to say?" value "" length 60
  end tell
  on error
    beep
end try

on affirmative_textfield_response(result_text)
  set the speakPhrase to result_text as string
  try
    tell application "SEC Helper"
      delay 1
      say ""
      show screen message speakPhrase
      say speakPhrase
    end tell
  on error
    beep
  end try
end affirmative_textfield_response

on negative_textfield_response()
  try
    tell application "SEC Helper"
      show screen message "Never mind!"
    end tell
  on error
    beep
  end try
end negative_textfield_response

Toggle Audio Outputs

This script will allow you to toggle between two Audio output options in the Sound Preference Pane, and will display the name of the selected output on the Mac's monitor and the T68i. Clicking "Yes" will quit System Preferences, "No" will keep System Preferences open.

I use this to toggle between my Mac's speakers, and an optical "TOSlink" connection to my home stereo. Used in conjunction with the iTunes scripts, I can now listen to my iTunes library on my home stereo without ever having to sit in front of my Mac. NOTE: This script requires Apple's GUI Scripting Component.

NEW! Stephane Brau helped identify a problem with this script while using a non-US English system. The script needs to be altered to use the proper names of the Preference Panes and controls in the language of your OSX installation. Here's the French version. (compiled AppleScript) Thanks for the help!

tell application "System Preferences"
  activate
end tell

tell application "System Events"
  tell application process "System Preferences"
  set frontmost to true
  click menu item "Sound" of menu "View" of menu bar 1
  if my wait4window("Sound") is false then return false
    tell window "Sound"
      tell tab group 1
        tell radio button "Output"
          click
        end tell
        (* You can add your own audio output descriptive text, such as "iMic USB Audio", in the next section. *)
        if (selected of row 2 of table 1 of scroll area 1) then
          set selected of row 1 of table 1 of scroll area 1 to true
          try
            tell application "SEC Helper"
              show screen message "Audio Out Option 1"
              enter popup mode text "Audio Out Option 1"
            end tell
          on error
            beep
          end try
        else
          set selected of row 2 of table 1 of scroll area 1 to true
          try
            tell application "SEC Helper"
              show screen message "Audio Out Option 2"
              enter popup mode text "Audio Out Option 2"
            end tell
          on error
            beep
          end try
        end if
      end tell
    end tell
  end tell
end tell

on wait4window(this_title)
  tell application "System Events"
    tell process "System Preferences"
      repeat with i from 1 to 60
        if the name of window 1 is this_title then return true
        delay 1
      end repeat
    end tell
  end tell
  return false
end wait4window

on affirmative_popup_response()
  tell application "System Preferences" to quit
end affirmative_popup_response

on negative_popup_response()
  (* Don't have to do anything...but keep this section for SEC Helper compatibility *)
end negative_popup_response