AppleScript: So macht Scripting richtig Spass2 min read
Reading Time: 2 minutesÃœber das Buch Mehr machen mit dem Mac habe ich bereits berichtet. Im Addisson Wesley Verlags Blog wird fleissig über Beispiele aus dem Buch geschrieben. Es wurden ganze zehn Beispiele veröffentlicht welche ich Euch natürlich nicht vorenthalten möchte.
Kürzlich wurde dann ein interessanter Beitrag zum Thema AppleScript und Automator veröffentlicht. Ein kleines Script sorgt dafür, dass man vom eigenen Mac freundlich begrüsst wird, iTunes gestartet wird, die Lieblingsplaylist abgespielt wird, die abonnierten Podcasts aktualisiert werden, Das Programm Mail gestartet wird und alle Accounts auf neue Mails geprüft werden. Nach einer kleinen Mail-Download-Pause schraubt das Script dann die Lautstärke runter, der Mac erzählt wieviele ungelesene Mails man hat und hebt die Lautstärke wieder an.
say "Good morning, Mitra. How are you?"
-- iTunes
tell application "iTunes"
   set the playlistNames to the name of every playlist
   if playlistNames contains "House Is Love" then
      set myTrack to track 1 of playlist "House Is Love"
   else if playlistNames contains "Meine Top 25" then
      set myTrack to some track of playlist "Meine Top 25"
   else
      set myTrack to some track of playlist "Musik"
   end if
   play myTrack
   updateAllPodcasts
end tell
tell application "System Events"
   if (get name of processes contains "Mail") then
      tell application "Mail"
         check for new mail
      end tell
   else
      tell application "Mail"
         launch
      end tell
   end if
   delay 60
end tell
tell application "Mail"
   set myMails to unread count of inbox
   if myMails is greater than 1 then
      set myMailText to "are " & (myMails as string) & " unread mails."
   else if myMails is 1 then
      set myMailText to "is one unread mail."
   else
      set myMailText to "are no unread mails."
   end if
end tell
tell application "iTunes"
   set oldVolume to sound volume
   repeat with theVolume from oldVolume to 25 by -2
      set sound volume to theVolume
   end repeat
   say "There " & myMailText
   repeat with newVolume from theVolume to oldVolume by 2
      set sound volume to newVolume
   end repeat
end tell
So, was will man noch mehr nach dem aufstarten des Mac’s. Auf diese Art und Weise lassen sich viele sich wiederholende Schritte im Tagesablauf automatisieren. Man muss noch nicht einmal grosse Script-Kenntnisse haben, den der ScriptEditor kann auch Aktionen aufzeichnen!
Einziger kleiner Nachteil, der Mac kann nur englisch. Bei der Aussprache von nicht englischen Ausdrücken klingt es eher witzig als hilfreich.