Syntaxtell app "SoundJam MP" to run DescriptionYou use the tell statement to identify the target of an AppleScript command: tell app "Photoshop 5.5" to run In this case, run is the Photoshop application's command. The tell simple statement only takes up one line of code and does not need to be completed with an end tell. You use the reserved word tell, followed by a reference to an object, such as the application "Finder," then the reserved word to preceding the actual command that you want to send to the object. tell statements can be nested within each other, such as using a tell simple statement inside a compound tell statement (one that involves several lines of code and finishes with end tell). ExamplesThis code tells the Finder to open Photoshop only if a certain amount of memory is available to the computer: tell application "Finder" (* largest free block is converted from bytes to megabytes then rounded off with the round scripting addition *) set freeMem to (round (largest free block / 1024 / 1024)) if freeMem > 50 then (* only open PS if there is a free memory block > 50 meg *) tell application "Adobe¬ Photoshop¬ 5.5" to activate (* tell simple statement *) else display dialog¬ "Freemem = " & freeMem & " Not enough memory for gluttonous Photoshop!" end if end tell This example occurs within a compound tell statement that targets the Finder. If the largest free block property of the Finder (which identifies the largest free block of available RAM on the computer) exceeds 50MB, then Photoshop receives an activate command as part of a tell simple statement.
|