Advertisement
Guest User

Alarm Applescript

a guest
Dec 5th, 2013
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --initialise windows
  2. tell application "System Events"
  3.     set visible of process "AppleScript Editor" to false
  4. end tell
  5.  
  6. --Check new mail
  7. tell application "Mail"
  8.     check for new mail
  9. end tell
  10.  
  11. --count unread emails
  12. set unreadCount to 0
  13.  
  14. set exlcudeMailboxes to {"Drafts", "Trash", "Sent", "Sent Messages", "Junk", "Spam", "Outbox"}
  15.  
  16. tell application "Mail"
  17.    
  18.     -- get mailboxes with unread count
  19.     set mailboxesWithUnreadMessages to mailboxes of accounts whose unread count is not 0
  20.     set localMailboxesWithUnreadMessages to every mailbox whose unread count is not 0
  21.    
  22.     -- loop through all accounts and mailboxes
  23.     set returnArray to {}
  24.     repeat with currentAccount in mailboxesWithUnreadMessages & localMailboxesWithUnreadMessages
  25.         repeat with currentMailbox in currentAccount
  26.            
  27.             -- get mailbox attributes
  28.             set mailboxName to name of currentMailbox
  29.             set mailboxCount to unread count of currentMailbox
  30.            
  31.             if mailboxName is not in exlcudeMailboxes then
  32.                
  33.                 -- increment total count
  34.                 set unreadCount to unreadCount + mailboxCount
  35.             end if
  36.            
  37.         end repeat
  38.     end repeat
  39.    
  40. end tell
  41.  
  42. -- get the time
  43. -- hours
  44. set timeStr to time string of (current date)
  45. set Pos to offset of ":" in timeStr
  46. set theHour to characters 1 thru (Pos - 1) of timeStr as string
  47. set timeStr to characters (Pos + 1) through end of timeStr as string
  48.  
  49. -- minutes
  50. set Pos to offset of ":" in timeStr
  51. set theMin to characters 1 thru (Pos - 1) of timeStr as string
  52. set timeStr to characters (Pos + 1) through end of timeStr as string
  53.  
  54.  
  55. set thetime to (theHour & ":" & theMin) as string
  56.  
  57. --play alarm file
  58. set volume output volume 100
  59. tell application "VLC"
  60.     activate
  61.     open "/Users/admin1/Downloads/alarm.mp3"
  62. end tell
  63. delay 5
  64.  
  65. --Say good morning
  66. set d to (date string of (current date))
  67. set volume output volume 80
  68. say "Good morning, it is time to wake up."
  69. say "It is " & d
  70. say "And the time is " & thetime
  71.  
  72. --say number of unread emails
  73. delay 1
  74. say "you have " & unreadCount
  75. if unreadCount is equal to 1 then
  76.     say "unread email"
  77. else
  78.     say "unread emails"
  79. end if
  80. delay 2
  81.  
  82. --load 720 ABC Radio
  83. tell application "Google Chrome"
  84.     activate
  85.     open location "http://www.abc.net.au/perth/programs/webcam_radio.htm?ref=listenliveradio"
  86. end tell
  87. delay 5
  88. say "Seven Twenty is now loading"
  89.  
  90. --load today's weather
  91. tell application "Google Chrome"
  92.     activate
  93.     open location "http://www.abc.net.au/perth/weather/"
  94. end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement