This How-To will show several common and useful AppleScript Condition scripts. Most will run correctly if you just paste them in to the “If script returns true” text field in the Conditions
tab.
-- Get the current hour set theCurrentHour to hours of (current date) -- compare it to see if it's in one of our ranges - between 8am -- and 10am OR between 4pm and 6pm -- -- Note, the number that is stored in theCurrentHour will be 0-23 if (((theCurrentHour ≥ 8) and (theCurrentHour < 10)) or ¬ ((theCurrentHour ≥ 16) and (theCurrentHour < 18))) then return true end if return false
return (on state of device "Office Lamp")
return not (on state of device "Office Lamp")
-- I/O devices can have multiple inputs, so you have to get -- the list of inputs first. For the I/O link, it only -- has one, so we just look at the first one in the -- list. set theList to binary inputs of device "Garage Door" return item 1 of theList
try with timeout of 1 second tell application "System Events" if (get name of every process) contains "iCal" then return true end if end tell end timeout end try return false
set theCurrentHour to hours of (current date) if ((theCurrentHour ≥ 8) and (theCurrentHour < 16)) then set theList to binary inputs of device "Garage Door" if ((item 1 of theList) and (value of variable "alarmStatus" = "away")) then return true end if end if return false
return (not (on state of device "Office Lamp") and (value of variable "isDaylight" = "false"))