AppleScripting
                                                                              Léo Hackin
                                                                              @leohackin
                                                                          leohackin.com.br :D




                                                                                   Giran Sieges
http://blog.dunkelstern.de/images/blog/programming/applescript-icon.png
O QUE É?

Linguagem        Apple      Scriptable
             +            +
 de script       Events       Apps


                   +

    OSA (Open Script Archtecture)
OSA
APPLE EVENT

Pode fechar por favor?



         OK!
APPLE EVENT

tell application "Adium" to quit



             true
APPLE EVENT




http://www.switchingtomac.com/wp-content/uploads/2008/12/adium_logo.png
http://cdn.zath.co.uk/wp-content/uploads/2011/02/ThingsRev01_Logo-242x242.jpg
SCRIPTABLE APP




set status message of pomodoro to "Ja volto"

   atributo          objeto          valor
AS PRINCIPAIS APPS DO
MERCADO SÃO SCRIPTÁVEIS
SCRIPTABLE APP
      tell application "Adium"

Oh      go online
ié!     go available
        go offline
        go away
        go invisible
        go to hell

      end tell
O COMANDO TELL



tell application "Finder" to close every window
O BLOCO TELL

tell application "Application"
   ...
   ...
   comandos para a aplicação
   ...
   ...
end tell
COMANDO SET



set nome to "Hackin"
LINGUAGEM COMPLETA

estruturas de      estruturas de
                                        variáveis
  controle           repetição




         objetos                   :D
PRA QUE SERVE MESMO?

Automatizar tarefas

Controlar apps via script

Acessar serviços web o/
                            }   Tudo ao mesmo
                                   tempo! :)
APPLESCRIPT EDITOR
AUTOMATOR

                                                                              Permite criar workflows
                                                                                 e tasks poderosas
                                                                                 integrando várias
                                                                               aplicações no melhor
                                                                              modo “for dummies”




http://whimsplucky.squarespace.com/storage/automator_icon.png?__SQUARESPACE_CACHEVERSION=1300158374379
AUTOMATOR




      ou quase for
    dummies! hahah :)
http://www.xboxkinecthacks.com/wp-content/uploads/2011/03/kid-hack.jpg




Hacking
BAIXAR IMAGENS DO SITE
EXPORTADOR DE CONTATOS
TROLLANDO O ADIUM
tell application "System Events" to if exists process "Adium" then

 tell application "Adium"

 
 set stati to every status where title is "Pomodorando"

 
 if (count of stati) is 0 then

 
 
 set pomodoro to make new status with properties
{title:"Pomodorando", status type:away}

 
 else

 
 
 set pomodoro to item 1 of stati

 
 end if

 
 set status message of pomodoro to "Vou responder em
$duration minutos"

 
 set autoreply of pomodoro to "Vou responder em
$duration minutos"

 
 set the status of every account whose status type is
available to pomodoro

 end tell
end if
FALANDO!


say "Hello world" using "Bruce"
REFERÊNCIAS
Giran Sieges - Applescript com @leohackin

Giran Sieges - Applescript com @leohackin