AppleScript è¦ãæ¸ã
TextMate, QuickSilver ã使ã£ã¦ãã㨠AppleScript ãæ¬ ãããªããã®ã«ãªã£ã¦ããã
ä»ã¾ã§è¦ããè¦ã¾ã㧠AppleScript ã使ã£ã¦ãããã©æãããã«ãããªãããã®ã§ãªãã¡ã¬ã³ã¹ã«ç®ãéãã¦ã¿ãã
ã¡ã¤ã³ã¯ã³ã¼ãã¨ä¸ç·ã« gist ã«ãgist ã«æ¸ããªãã£ãè¦ãæ¸ããããã«ã¡ã¢ã
å¦ã³çµããä»ã¯ MacRuby é å¼µãï¼ï¼ã®æ°æã¡ã§ãã£ã±ãã§ãã
AppleScript is an object-oriented language. An object is an instantiation of a class definition, which can include properties and actions. "script" is the top-level object, which is the overall script we are working in.
èªç¶è¨èªçãªè¦ãããæã¦ãããè¨è¨ãããè¨èªã§ãé¢ç½ããã©ã¨ã£ã¤ãæªãããã«æãã
-- ãªãã¸ã§ã¯ãã®ããããã£ã of ã§è¾¿ãã as integer ã§ãã£ã¹ã (coercion) -- log ã say 㯠utf-8 ã¯ã©ã¹ãæ±ããªãã®ã§æ³¨æ log(size of first file of window 1 of application "Finder" as integer)
handlerãæè¬é¢æ°ã®å®ç¾©ã¯
-- æ®éã½ãå½¢ -- AS ã£ã½ãäºãããã人㯠log ã«ä»£ã㦠say ã使ãã¨ã on rock(clock) log (clock as text) end rock rock(current date) -- ãããæ¸ãã on rock around clock log (clock as text) end rock -- å¼ã³åºãå´ãå¤ããã() ã§ã¯å¼ã¹ãªãã rock around current date -- optional ã« the ã使ãã on rock around the clock log (clock as text) end rock -- ãã¡ãã® the ãçç¥å¯è½ rock around the current date
æ´ã«
-- labeled parameters to findNumbers of numberList above minLimit given rounding:roundBoolean end findNumbers -- call findNumbers of myList above 19 given rounding:true -- ããã㯠findNumbers of {5.1, 20.1, 20.5, 33} above 20 with rounding findNumbers of {5.1, 20.1, 20.5, 33.7} above 20 without rounding -- patterned positional parameters on hl({x,y}) log x * y end hl hl({10, 20})
ã·ã§ã«ã¹ã¯ãªããå®è¡
-- ã·ã§ã«ã¹ã¯ãªããå®è¡ log (do shell script "cd ~; ls") -- Technical Note TN2065, do shell script in AppleScript. -- http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
tell ã«ã¤ãã¦ãScriptEditor ã«ã¦æ¬¡ãå®è¡ãã
log name of window 1 as text tell application "Finder" log name of window 1 as text end tell log name of window 1 of application "Finder" as text
ã©ã®ãªãã¸ã§ã¯ãã«ã¡ãã»ã¼ã¸éä¿¡ããããã«ããçµæãå¤ãã£ã¦ããã
... of me ã my ... ã§ã¹ãã¼ãã¡ã³ãåä½ã§ã³ã³ããã¼ã«åºæ¥ãã tell ã使ãã¨ãããã¯å
ãæ¬ããã
tell ã®å¤é¨ã¨å é¨ã§ã¯ã¹ã³ã¼ããç°ãªãã®ã§å¤é¨ã§å®ç¾©ããã¦ãããã³ãã©ã®åç §ã«ã¯ my ã of me ãå¿ è¦ (me ã¯ã¹ã¯ãªããèªä½ãæã)
tell application "Finder" my fn(name of window 1) end tell on fn(x) log x & "!!!" end fn
ã·ã§ã«ãã AppleScript ã使ã
#!/usr/bin/osascript
osascript -e 'tell app "Address Book" to get the name of every person' | perl -pe 's/, /\n/g' | sort | uniq