UPDATE: I've made a few changes to filter out corner cases. This script is a daily life saver.
UPDATE AGAIN: Now supports Mountain Lion Messages as well.
-- Run via crontab: 0,1,29,30,31,59 8-18 * * 1,2,3,4,5 osascript /Users/jcoates/bin/meeting-test.scpt > /Users/jcoates/Library/Logs/meeting-test.logset Cals2Check to "Calendar,Solutions"set curdate to current dateset tomorrow to (current date) + 86400set delims to AppleScript's text item delimitersif Cals2Check contains ", " thenset AppleScript's text item delimiters to {", "}elseset AppleScript's text item delimiters to {","}end ifset caltitles to every text item of Cals2Checkset AppleScript's text item delimiters to delims-- if Outlook isn't running, let's just move alongtell application "System Events"set outlook_running to (name of processes) contains "Microsoft Outlook"end tellif not (outlook_running) thenquitend iftell application "System Events"set adium_running to (name of processes) contains "Adium"end telltell application "System Events"set messages_running to (name of processes) contains "Messages"end telltell application "System Events"set skype_running to (name of processes) contains "Skype"end telltell application "Microsoft Outlook"--We need to get the ID of each calendar, as the names are not always unique (this may be an issue with mounted shared calendars)set calIDs to {}repeat with i from 1 to number of items in caltitlesset caltitle to item i of caltitlesset calIDs to calIDs & (id of every calendar whose name is caltitle)end repeat--Now we get a list of events from each of the calendar that match our time criteriaset calEvents to {}repeat with i from 1 to number of items in calIDsset CalID to item i of calIDstell (calendar id CalID)-- find events that are currently active and truly busy. filter out the really long ones.set calEvents to calEvents & (every calendar event whose (start time < (curdate)) and (end time > (curdate) and (end time < (tomorrow)) and (free busy status = busy) and (all day flag = false)))end tellend repeatif number of items in calEvents > 0 then-- I'm in a meeting, so quiet downtell application "Microsoft Outlook"-- set working offline to trueset display alerts to falseend tellif (adium_running) thentell application "Adium"go invisible-- quitend tellend ifif (messages_running) thentell application "Messages"log out-- quitend tellend ifif (skype_running) thentell application "Skype"send command "SET USERSTATUS INVISIBLE" script name "AppleScript status setter"-- quitend tellend ifreturn (curdate & "shhhhhhhh" & subject of item 1 of calEvents)else-- I'm not in a meeting, so tell me thingstell application "Microsoft Outlook"-- set working offline to falseset display alerts to trueend tellif (adium_running) thentell application "Adium"-- rungo availableend tellend ifif (messages_running) thentell application "Messages"log in-- quitend tellend ifif (skype_running) thentell application "Skype"-- runsend command "SET USERSTATUS ONLINE" script name "AppleScript status setter"end tellend ifreturn (curdate & "let's play!")end ifend tell