Enhancing iLife with AppleScript

With the exception of iMovie, the iLife applications (and the iPod, as well) are scriptable. This means that you can write AppleScript code to automate repetitive tasks, communicate data from one program to another, and perform operations that are inaccessible from the program's menus and buttons.



Even if you don't want to learn to program, you shouldn't skip over this material. Untold numbers of useful AppleScripts are ready for you to use. You don't have to know C++, Objective-C, Pascal, Java, or some other language to use programs written by others in these languages for iMovie, iTunes, iPhoto, iDVD, Photoshop, and so on.



Of course, if you're a little curious and willing to put some time and effort into learning AppleScript programming, you'll have an even richer experience because most of the AppleScripts you can download are easily modifiable.



Scripting iTunes


Of all the iLife applications, iTunes has the longest, richest AppleScript history and the greatest AppleScript support. iTunes even includes a Scripts menu (the little scroll icon between Window and Help) to provide easy access to your iTunes scripts. These scripts live in one of the following locations:



  • A Scripts folder contained in your Home Library's iTunes folder

  • A Scripts folder in the iTunes folder of your startup disk's Library folder

The scripts in your startup disk's Library folder are accessible to any user on your Mac running iTunes. The scripts in your Home Library's iTunes folder are accessible only by you.



AppleScripting iPhoto


Although iPhoto doesn't offer a Scripts menu of its own, you can get the same effect by using the system-wide Scripts menu. Inside the AppleScript folder within your Applications folder is a file that bears a folder icon named Script Menu.menu. Double-click this folder icon to add a system-wide Scripts menu to the right side of your menu bar. The system-wide Scripts menu provides a home for the scripts used with applications that don't provide Scripts menus of their own.



Apple makes a nice assortment of example scripts available at Apple.com. Not only are these great examples from which you can figure out scripting techniques, but most of them are also extremely useful in their own right. One example, Find Unassigned Images, creates an album for you consisting only of images from your photo library that aren't already in at least one album. Not only is that script useful, but you can also easily modify the script to create a list of albums to which an individual photo belongs.



AppleScripting iDVD


As with iPhoto, you can most easily access iDVD's scripts by using the system-wide Scripts menu. A good starter set is available at Apple.com.



Even as handy as those scripts are, a full-blown application named iDVD Companion is available from the AppleScript iDVD Web page. iDVD Companion is written in AppleScript Studio, a pure OS X development environment where you use AppleScripts to do your work and Apple's development tools (they're part of your OS X distribution but aren't installed by default) to create the user interface. Note that some scripts may not work with the current version of iDVD.



The iDVD Companion window contains the following tabs:



  • Nudge: Use this tab to move selected buttons in 1-, 6-, 36-, or 72-pixel increments to the left, right, up, or down.

  • Align: With this tab, you can line up the left, right, top, or bottom edges of two or more selected buttons.

  • Title: This tab sets the location for the menu's title.

The iDVD Companion menu bar includes other helpful shortcuts. In addition to the Select Back Button choice, the Edit menu also includes commands that allow you to Select All buttons, Deselect All buttons, and Delete All buttons. Be careful, though, with the Delete All buttons command; no undo is available.



Navigating your menu structure in iDVD to make changes to subordinate menus can be time-consuming and annoying. iDVD Companion provides a Go menu that enables you to select your destination menu from a list and then tells iDVD to display that menu, eliminating the need to navigate a possibly complex menu structure. The Themes menu sports a handy little Layouts submenu with four predefined button layouts. The Button menu enables you to name buttons, specify exact positions for buttons, and swap the positions of two selected buttons.



One of the better features of iDVD Companion is that all these palette and menu operations take place by calling AppleScripts, and the source code for all those scripts is present for you to look over and modify as you desire.



dummies

Source:http://www.dummies.com/how-to/content/enhancing-ilife-with-applescript.html

No comments:

Post a Comment