AppleScript 㧠iPhone ç¨ã«åç»ãå¤æããä½æ¥ãèªååããï¼ãã ãï¼é¢åãªã¨ãã㯠Ruby ã«ä»»ããï¼
æè¿ï¼MacBook Pro ã«ããã¦ããåç»ã iPhone ã§ãè¦ãããããã«ããããªãã¾ããï¼ãããï¼iPhone ã§åçã§ããã®ã¯ .m4v å½¢å¼ãªã®ã§ï¼ãã®å½¢å¼ã«åç»ãå¤æããå¿ è¦ãããã¾ãï¼å¹¸ãï¼Mac OS X ã«ä»å±ã® QuickTime Player 7 ã使ãã° iPhone ç¨ .m4v ãä½æã§ããã®ã§ï¼ãã¡ã¤ã«ãä¸ã¤ä¸ã¤éãã¦ãã¦ã¹ã§ã«ãã«ããã£ã¦ããã°ï¼ãããã¯å ¨é¨ .m4v ã«ãªãã¾ãï¼ãããï¼ãã®æ¹æ³ã§ã¯ãã£ã¨ 13 ãã¡ã¤ã«ç®ãããã§å¿ãæããã®ã§ï¼AppleScript ã使ã£ã¦ä½æ¥ãèªååãããã¨ã«ãã¾ããï¼
AppleScript ã¨ã¯
AppleScript ã¨ã¯ Apple 製ã®ã¹ã¯ãªããè¨èªã§ï¼Mac ã®ã¢ããªã±ã¼ã·ã§ã³ãã¹ã¯ãªããããæä½ããããã«å©ç¨ããã¾ãï¼AppleScript 㯠Mac OS X ã®ä¸é¨ã¨ãã¦æä¾ãããã®ã§ï¼é¢åãªã¤ã³ã¹ãã¼ã«ã¯ä¸è¦ã§ãï¼AppleScript ã使ãã°é¢åãªä½æ¥ãèªååãããã¨ãã§ãã¾ãï¼
AppleScript ãåå¼·ãã¦ã¿ã
AppleScrip ãä½ãåãã£ãã¨ãã㧠AppleScript ãåå¼·ãã¦ã¿ã¾ãï¼
ã¢ããªã±ã¼ã·ã§ã³ã¸ã®ã³ãã³ãã®éãæ¹
AppleScript ã§ã¢ããªã±ã¼ã·ã§ã³ãæä½ããã«ã¯ï¼ã¢ããªã±ã¼ã·ã§ã³ã«ç¸å½ãããªãã¸ã§ã¯ãã«ã³ãã³ããéãã¾ãï¼ã¢ããªã±ã¼ã·ã§ã³ã«ã³ãã³ããéãã«ã¯ï¼
tell application ã¢ããªã±ã¼ã·ã§ã³å
ä¸ã¤ãã®ã³ãã³ã
äºã¤ãã®ã³ãã³ã
...
end tell
ã¨ï¼tell æã使ãã¾ãï¼iTunes 㧠"My Top Rated" ã¨ãããã¬ã¤ãªã¹ããåçã㦠5 ç§å¾ã«åæ¢ããã¹ã¯ãªãããä¾ã«æããã¨ï¼
tell application "iTunes" play the playlist named "My Top Rated" delay 5 stop end tell
ã¨ãªãã¾ãï¼
ãã¡ã¤ã«ã®æ±ãæ¹
ããã¤ãã®ã³ãã³ãã¯ï¼ãã¡ã¤ã«ãæ±ãã¨ãã«çµ¶å¯¾ãã¹æååã§ã¯ãªããã¨ã¤ãªã¢ã¹ããå©ç¨ãã¾ãï¼çµ¶å¯¾ãã¹æååããã¨ã¤ãªã¢ã¹ãä½ãã«ã¯ï¼
set fooAlias to POSIX file "/path/to/file"
ã¨ãã¾ãï¼
AppleScript ã®åå¼·ãããããã¦ã¿ã
ã¨ï¼ããã¾ã§ AppleScript ã®åºæ¬ãåå¼·ããã¨ããã§ï¼AppleScript ã®ä¿®å¾ãããã¾ãï¼AppleScript ã¯åã«ã³ãã³ããçºè¡ããã ãã§ã¯ãªãï¼å¶å¾¡æ§é ããã£ãããã°ã©ãã³ã°è¨èªãªã®ã§ãï¼ãããï¼ç§ã«ã¨ã£ã¦å¶å¾¡æ§é ãæ¸ãã®ãªã Ruby ã®ã»ãã楽ãªã®ã§ï¼AppleScript ã¯ã¢ããªã±ã¼ã·ã§ã³æä½ã®ã³ãã³ããçºè¡ããããã ãã«ä½¿ãï¼ä»ã®é¨å㯠Ruby ã§æ¸ãã¾ãï¼
osascript(1)
ã³ãã³ãã©ã¤ã³ãã AppleScript ãå®è¡ããã«ã¯ osascript(1) ãå©ç¨ãã¾ãï¼Ruby ãã AppleScript ãå®è¡ããæ¹æ³ã¨ãã¦ã¯ RubyCocoa ã使ãæ¹æ³ãããã®ã§ããï¼ç°¡åãªã®ã§ãã¡ãã使ãã¾ãï¼osascript ã«ã¯æ¨æºå ¥åãã AppleScript ã渡ãã¾ãï¼
ã§ããããã°ã©ã
以ä¸ã®ç¥èãå©ç¨ãã¦ããã°ã©ã ãæ¸ãã¦ã¿ã¾ããï¼ä¾ã«ãã£ã¦ gist ã§ã¯ãã¤ãã¾ãï¼
ãã®ããã°ã©ã ã使ãã«ã¯ï¼ã³ãã³ãã©ã¤ã³ããï¼
$ /usr/bin/ruby movie_importer.rb foo.mpg bar.mp4 ...
ãªã©ã¨ãã¾ãï¼
ãããã«
iPhone ç¨ã«åç»ãå¤æããä½æ¥ã AppleScript ã§èªååãããã¨ãã¾ãããï¼éä¸ã§é¢åããããªã£ã¦ Ruby ã使ãã¾ããï¼æ¬å½ã¯ AppleScript ã使ããªãã¦ã RubyCocoa ã® QTKit çµç±ã§ Ruby ã ããã§åããã¨ãã§ããã®ã§ããï¼ãæ軽ãªæ¹æ³ã§ç®çãéæããã®ã§ï¼ããã§çµããã¨ãã¾ãï¼
åè
- Doug's AppleScripts for iTunes » AppleScript Basics
- iTunes ãæä½ããã¹ã¯ãªããã®ãµã³ãã«ãè±å¯ã«ããåèã«ãªãã¾ã
- AppleScript Editor ã® [Window] ã¡ãã¥ã¼ãã [Library] ãé¸æãã¦è¡¨ç¤ºããã API ãªãã¡ã¬ã³ã¹
- QuickTime Player 7 ã®ã³ãã³ãã調ã¹ãã®ã«ä½¿ãã¾ãã