Skip to content Skip to sidebar Skip to footer

Applescript Editor 2.0 Download Mac Updated

Applescript Editor 2.0 Download Mac

Chapter 1. Setting Upward AppleScript

Although AppleScript is fast and free, perhaps the best part about it is that information technology gets installed right along with Mac OS X. You don't need to download any files, install whatsoever CDs, or configure any nasty system files to get AppleScript to work. In fact, you've got an AppleScript binder tucked inside your Applications folder, right this very moment.

Figure ane-i. The Applications AppleScript binder has everything you need to start writing your own scripts. Since you're going to be spending a lot of time hither, it's a skillful idea to put this folder in your Dock.

Notation

If yous don't have this folder, chances are y'all're not running Mac OS X Panther. See Section P.4.3.ane for instructions on how to upgrade to the latest version, Mac OS X Panther (version 10.3).

Whenever you install Mac OS X—or buy a new Mac—you lot'll observe these 5 icons in your AppleScript folder:

  • Example Scripts is merely an alias (shortcut) to your Library Scripts binder. This folder contains more than 100 example scripts for you to run, examine, and edit (Department 1.1.one).

  • Folder Deportment Setup turns on the powerful folder actions characteristic of Os X. One time it's on, you can make the Finder run your very own scripts whenever you open up a folder, add an icon to a folder, remove an icon from a binder, and then on. (A total explanation of Folder Actions appears on Chapter eleven.)

  • Install Script Carte adds a new icon to the correct side of your menu bar. With this menu in place, you tin can hands run your favorite AppleScripts from whatsoever program you want (read on for details).

  • Remove Script Menu hides the carte du jour that appears when you double-click Install Script Menu.

  • Script Editor is AppleScript Central. From at that place you can open up, edit, and run your scripts, and save them in whatsoever number of special formats. Script Editor coverage starts on Chapter 2.

Now that you know what you've got, it'due south all-time to spend some time getting acquainted with all the AppleScript stuff that's already on your Mac. Pop open a new Finder window—past choosing File New Finder Window, for example—and and so click the Applications binder icon in the Sidebar. Once in the Applications folder, open up the AppleScript folder, and you're ready to explore.

The Script Menu

To get your commencement sense of taste of AppleScript, double-click Install Script Menu. When you do and so, a curled-parchment icon appears right in your menu bar. (This icon is a recurring theme in Mac Bone X that means, roughly, "What yous're looking at has something to do with AppleScript.") Just click the menu bar icon once to display the Script Menu (Figure 1-1).

Annotation

All the scripts that appear in the Script Bill of fare come from the Library Scripts binder. And, equally described on Department 1.i.16.one, that means you can add your own scripts to the Script Bill of fare in addition to tweaking the existing ones.

You tin run whatever script simply by selecting its proper noun from the advisable submenu. The following sections provide a breakdown of what the scripts do.

Address Book Scripts

Hither, you'll discover a single Import Addresses script, designed to move your contacts into Mac Os Ten's Accost Book from other applications, such every bit Entourage, Outlook Express, Palm Desktop, Eudora, Claris Emailer, and Netscape. If you've got a lot of friends, this script saves yous from having to re-enter all their names, phone numbers, and e-mail addresses by hand.

Note

The scripts in the Helper Scripts submenu (just above Import Addresses ) are off-limits to mere mortals. If you attempt to run any of the Helper Scripts , Mac OS X simply tells you to utilise the Import Addresses script instead.

Figure ane-two. The Script Bill of fare is your key to running AppleScripts from but near whatever programme. However, if you're using a plan with a lot of menus (Word or Photoshop, for example), that plan may clip off the Script Menu. To motion the Script Card to a less clip-prone position, only -drag its icon farther to the right.

Basics

In this submenu, you'll find three small, handy scripts:

  • AppleScript Assist launches Assistance Viewer and displays a fairly random listing of every AppleScript help file on your Mac.

Note

To come across a more orderly list of such files in Help Viewer—organized past Apple for quick reference—choose Library AppleScript Help and then click Browse AppleScript Help.

  • AppleScript Website opens the AppleScript domicile page (http://www.apple tree.com/applescript/) in your default Spider web browser.

  • Open Script Editor launches the Script Editor plan from your Applications AppleScript folder. Meet Affiliate 2 for more than on this powerful program.

ColorSync

This submenu contains almost 20 unlike scripts for working with ColorSync (a technology for matching colors between pictures, figurer screens, printers, so on). When y'all select a script from this submenu, it presents a short dialog box explaining what it does. Here are some of the highlights:

  • Build profile info web page presents an Open dialog box for picking a folder of pictures. Once you've done and so, the script generates a Web page containing each epitome, along with a description of which profile (colour settings) information technology uses.

Note

Even if y'all don't employ ColorSync, this script can be quite handy; information technology's a neat way to chop-chop generate a Web page from the pictures in a binder.

  • Mimic PC monitor adjusts your screen so the color settings are similar to those of a Windows PC. (This script is especially useful if you're a Web designer, since information technology shows you lot how your Web pages will likely wait to Windows users all over the globe.)

  • Remove contour from image takes any special colour settings out of a moving-picture show, so y'all're left with the raw, unfiltered colors that were there to begin with. If y'all're trying to gauge the accuracy of your digital photographic camera's color settings, this script is a helpful tool.

Finder Scripts

This submenu contains a agglomeration of timesaving scripts for working with files in the Finder:

  • AboutFinder Scripts simply presents a dialog box explaining how the scripts work.

  • Add to File/Folder Names lets you tack the aforementioned prefix or suffix onto every particular in the active Finder window (Figure 1-2).

Note

If there aren't whatever Finder windows open, this script (and all the other Finder scripts) works with the files or folders on your desktop instead. That means, for instance, that the Add to File Names script appends your called extension to every file on the desktop if there aren't any Finder windows open.

  • Change Example of Item Names lets you lot make every file and folder in the electric current Finder window either all upper-case letter or all lowercase. If you lot pine for the days of DOS—where every file name was in capital letters—this script is for you.

  • Finder Windows - Hide All minimizes all your Finder windows, ane at a time, to the Dock.

Note

A faster way to minimize all your Finder windows is to simply Option-click the yellow minimize button in whatever single Finder window. That style, the windows all minimize simultaneously, rather than one at a time.

Effigy 1-3. If you have a lot of files that you're bringing over from Mac Bone 9 or your digital photographic camera, there'southward a expert risk that they're missing file extensions (abbreviations like .jpeg and .txt that let them open up in Mac OS X). The hard fashion to add these extensions is to rename each file by hand (peak). The easy mode: in the Script Menu, choose Finder Scripts Add to File Names, enter the file extension you desire to append, and click Suffix (bottom).

  • Finder Windows - Show All brings dorsum all your Finder windows from the Dock.

  • Replace Text in Item Names does a notice-and-supercede on every file proper name, folder name, or both in your active Finder window (Figure 1-3).

  • Switch to Finder brings the Finder to the front and hides every other program.

Annotation

Yous can accomplish the aforementioned task by Option-

image with no caption

-clicking the Finder icon in the Dock.

  • Trim File/Folder Names cuts off any prefix or suffix you specify (by clicking Trim Kickoff or Trim Terminate, respectively). Information technology's basically the reverse of the Add to File/Folder Names command described earlier.

Figure one-4. Batch-renaming items is a four-step process. Top: Choose whether y'all want to apply the operation to files, folders, or both. Second from superlative: Enter the text you desire to replace (it's not case-sensitive). Second from bottom: Enter the text you want to substitute. Bottom: Confirm your pick and scout in anaesthesia equally AppleScript renames all the files that match your text.

Folder Actions

These scripts turn on and off folder deportment— scripts that run automatically in the Finder—either for the entire organization or just for a specific binder. (Folder action coverage begins on Chapter 11.)

FontSync Scripts

If yous spend your life doing visual layout or press, you may accept come across FontSync profiles (little summaries of all the fonts on someone'southward reckoner). You lot tin easily generate such profiles (using Create FontSync Profile ) or compare your own profile to someone else's (using Match FontSync Contour ) to come across if you lot have the same fonts. Beyond that, though, there'south not much you can do with the AppleScripts found in this submenu.

Info Scripts

The two scripts in this submenu are pretty much duplicates of existing Mac Os X features:

  • Current Date & Time displays a dialog box with—yous guessed information technology—the current date and time. The just existent benefit to this command is that information technology has a Clipboard button; when you click that, the date and time information is copied to the Clipboard, so y'all tin can paste (

    image with no caption

    -V) that information into a document window, such as one from TextEdit, Mail service, or Microsoft Discussion.

  • Font Sampler displays every font you have on your reckoner in its own typeface (Effigy 1-four). Of course, y'all can ever preview your fonts with Font Volume (found in your Applications binder), but that's not nearly as fun as being able to see how all your fonts look at once.

Effigy one-5. Each sentence here is supposed to comprise every alphabetic character of the alphabet, so you tin encounter exactly how each letter appears in each typeface. Of course, whoever programmed this feature forgot that the sentence "The quick brown fox jumped over the lazy domestic dog" is missing the letter "s" (it should say "jumps" instead of "jumped").

Internet Scripts

With the exception of the first script in this folder, these scripts go out and troll the Internet to fetch data for yous:

  • Nearly Cyberspace Services Scripts presents a dialog box with a link to additional Spider web services. (See Sidebar 9.six for more well-nigh using AppleScript with Web services.)

  • Current Temperature by Zipcode gives y'all the temperature exterior your firm in both Fahrenheit and Celsius, assuming you live in the United States.

  • Stock Quote fetches a xx-minute delayed stock quote for the ticker symbol of your pick.

Note

If you lot don't know a visitor's ticker symbol, visit http://finance.yahoo.com/ to wait it up. But if y'all want to quickly come across how Apple tree's stock is performing, merely click the OK push button when the dialog box appears. (The script automatically inserts AAPL, Apple's ticker symbol, into the dialog box.)

Mail Scripts

This submenu contains a collection of scripts that work with Mac Os X'southward built-in Mail programme (Section 9.4).

Note

If you lot utilize a different email programme, y'all're out of luck; these scripts work only with Post.

  • Count Messages in All Mailboxes is a convenient way to tell how much spam you've been getting. Of class, that's not what this script is meant for—it's simply supposed to tell you how much email you have in each mailbox. If you lot're like virtually people, though, your spam count will far outweigh anything else you accept in your mailboxes, rendering this count almost useless.

  • Crazy Bulletin Text is a great way to ship electronic greeting cards, birthday wishes, or ransom notes (Figure 1-5).

Figure 1-6.Top: Enter your text in the Crazy Message Text dialog box. You can customize the range of font sizes in the message past clicking Gear up Prefs. Bottom: In one case you click Keep, you terminate up with a randomly formatted jumble of text, perfect for avoiding handwriting detection.

  • Create LDAP Server is worthless unless you're on a corporate network. If you are, though, you lot may take access to an LDAP server (basically, a virtual employee directory). Your network administrator can assist you fill out the dialog boxes.

    Once you've set upwardly an LDAP server in Mail, you'll be able to type the first few letters of an employee's email address and have the rest of the address filled in for you automatically. (Of course, it might not exist worth all that trouble to configure an LDAP server if you've already got all your contacts in Address Volume.)

  • Create New Mail Account prompts you for everything yous demand to gear up a new email business relationship. There's not much do good to this multi-dialog box script, however, when you tin set up a new business relationship all at once in Mail Preferences Accounts.

  • Create New Message takes you, dialog box by dialog box, through everything you need to make a new electronic mail message. The simply benefit of using this script (instead of creating a new message in Mail itself) is that y'all don't take to bring Postal service to the front first.

  • Display All Accounts and Preferences puts together a new electronic mail message containing every imaginable statistic about your email settings. This script even attaches a copy of Mail'due south preference files for your perusing pleasure.

  • Get Size of IMAP Mailbox is perfect for figuring out how full your .Mac mailbox is—if you've signed up for Apple's .Mac service, that is. Simply select an email account, allow Mail service synchronize its database with your mail server, and wait a few minutes. When Mail is done calculating, you'll meet a new email bulletin telling you how much infinite your electronic mail is taking up on the server.

  • Import Addresses is identical to the Address Volume version described on Section 1.1.ane. In other words, this script lets you import your contacts from a third-party programme—like Microsoft Entourage—into Mac OS X's Accost Book. (Once you exercise and so, all your former contacts volition exist available in Postal service besides.)

Note

The Helper scripts aren't much help here either. Just like in the Address Book scripts, y'all tin can't run these Helper scripts yourself.

  • Manage SMTP Servers lists all the outgoing email servers that Mail service is set up to use just that you're not using to send mail. If y'all deleted an electronic mail account but forgot to delete all the server settings that went with it, for instance, this script can help y'all track down the orphaned settings.

  • Dominion Actions lets y'all run AppleScripts whenever email that matches certain criteria arrives. Check out Help with Rule Deportment for more information on using this powerful feature, or see Sidebar 9.iv for an case of rule actions in action.

All the AppleScripts found in the Scripts Menu submenu only work from within Mail: just select an e-mail message and cull the script you desire to run. For more detailed explanations, cheque out Sidebar 1-3.

Navigation Scripts

This subfolder contains scripts that let you bound to a item folder in the Finder, correct from the carte bar of any program.

Note

If the folder you want to open doesn't take its own defended script, just choose from the extended folder listing in Open up Special Folder.

Printing Scripts

Each of these scripts helps y'all ship something to your printer:

  • About "Convert"/"Print Window" Scripts provides some tips for using these scripts with multiple files at once.

  • Convert to PDF/PostScript takes any graphics or plain text files you've selected in the Finder and converts them to either PDF or PostScript format. This is a great tool if your Mac is connected to a shared printer on your network, for example, merely you don't want to shell out hundreds of dollars for a dedicated PostScript converter (a necessity for using many network printers). Instead, just utilise this PostScript-converting script and send the resulting file straight to your printer using Printer Setup Utility (in your Applications Utilities folder).

  • Impress Window is a handy replacement for the old Impress Window command from Mac Bone 9's Finder. This script lets y'all generate a printout of all the items within whatsoever folder you choose (with no icons, alas), to mail service on your refrigerator maybe.

Annotation

The Print Window with Subfolders script is the aforementioned, except that information technology prints a list of all the folders' subfolders every bit well.

Script Editor Scripts

This submenu is filled with dozens of helpful scripts for getting the nearly out of Script Editor. For a quick summary of what the scripts do, choose "Well-nigh these scripts." Or, for a more detailed explanation of using these scripts while writing your own lawmaking, turn to Sidebar 2.3.

Sherlock Scripts

OK, "scripts" is a chip of a misnomer—there's only ane script hither. Yet, it's a useful one: Search Internet lets you lot enter any text and take Sherlock check the results from five search engines simultaneously. The results come back in an easy-to-browse list, ranked by how relevant each site is to your search terms.

UI Element Scripts

The scripts in this menu are all demonstrations of AppleScript'due south GUI Scripting capability, for controlling programs' interfaces. These scripts probably won't make much sense to you, all the same, until y'all've read Chapter 12, which explains how GUI Scripting works.

Notation

You can't run any of these scripts right from the Script Card; y'all have to run them from Script Editor (Section 2.1.one.three) instead.

URLs

This final set of scripts provides quick links to some Web sites. All of these scripts use your default Spider web browser—which for most Mac OS X users is Safari, unless you lot specify a different browser (such equally Camino, Firefox, or even Internet Explorer) in Safari Preferences General.

  • Apple Stock Quote (Yahoo) displays detailed financial information for Apple tree Computer.

Notation

If you want a stock quote for any other company, choose Internet Scripts Stock Quote. Unfortunately, using that other script doesn't provide whatsoever of the detailed news, graphs, and statistics that Apple's own stock quote script does.

  • Apple tree Store brings yous straight to Apple's online retail shop, http://shop.apple.com/.

  • AppleScript Related Sites contains scripts for jumping to 3 of the most popular AppleScript sites on the Web. (Come across Department C.1 for more AppleScript-related Web sites.)

  • CNN takes you right to the pop online news site.

  • Download Atmospheric condition Map fetches an up-to-the-minute weather condition map of the continental The states and saves it as weathermap.jpg on your desktop. The script and then goes one stride further and opens the file in your favorite image viewer (by default, the Preview programme). Effigy 1-six has the details.

Figure i-vii. Unless yous've specified a different program to open JPEG files in the Finder, your atmospheric condition map opens in Preview (shown hither). Of grade, if you're not a meteorologist, this map may not be very helpful to you; if that's the instance, cheque out Internet Scripts Electric current Temperature past Zipcode for a more digestible take on the weather outside.

  • Macintouch brings you to the popular in-the-know Mac news site.

  • MacWeek is a poor championship for this script, as it actually takes you lot to MacCentral, a news site run by Macworld magazine.

Customizing the Script Carte du jour

At this point, you probably remember the Script Menu is a pretty handy tool for running the scripts on your Mac. Even so, the Script Card is much more than just a tool for launching the scripts that come up with Mac Bone X. Hidden backside its humble icon in the menu bar is enough ability to continue any Mac person engrossed for hours.

For case, you tin:

  • Add together new scripts to the Script Card . Or, if you're a clutter nut, you can remove some of the useless scripts that come with the carte.

  • Rearrange the submenus . Since the Script Bill of fare just mirrors a folder that lives on your organisation (constitute in Macintosh HD Library Scripts), you lot can move scripts around and customize the Script Card to arrange your needs.

  • Tweak the scripts themselves . Ready Apple'due south spelling oversights (Effigy i-4), for instance, or insert AppleScript commands of your own into the built-in scripts.

Adding new scripts

Afterward you utilise the Script Bill of fare for a while, you'll probably get bored with the option of scripts that Apple ships along with Mac Os X. Luckily, you can take any script yous desire—for example, an AppleScript yous write yourself, or one you download from a Web site listed on Department C.1—and add it to your Script Menu.

Say you desire a script that'll speak the time and temperature out loud. You can search online for an AppleScript that does just that, and once you lot download the script, you tin add it to your Script Card equally follows:

  1. Download the script you want from the Net .

    In this case, the script yous want is available from http://files.macscripter.net/scriptbuilders/Utilities/SayYourTimeAndTemperature.sit.

    Note

    If the downloaded file doesn't expand itself automatically, simply double-click its icon in the Finder.

  2. Open the Macintosh Hd Library Scripts folder .

    This is the Library folder that's located at the root of your Mac'south hard drive (not to be dislocated with your personal Library folder, described on Sidebar ane.ii).

  3. Elevate the script you simply downloaded and driblet information technology into whatever of the folders in the Finder window .

    Because this new script uses the Internet to access its information, an advisable folder would exist Internet Services.

    Note

    Yous tin can put the script in whichever folder you want, and you can fifty-fifty name it whatever you want. For this script (originally named SayYourTimeAndTemperature ), a more concise name might be Time and Temp , for case. (To rename a file, select it, press Return, type the new proper name, and printing Return again.)

  4. Open the Script Card and run your new script (Figure ane-7) .

    The script opens Accost Book in the background to find your dwelling address and then "speaks" out loud the temperature and time for your expanse (using the default system voice you lot've chosen for your Mac via System Preferences Speech Default Vocalism).

Rearranging submenus

Information technology'due south nice that Apple tree took the time to organize the scripts in the Script Menu into different submenus, but sometimes it seems like their choices were just plain random. Why, for example, aren't the Finder scripts and Navigation scripts combined in the same folder when both sets of scripts work with the Finder?

Figure one-8. If you rename the script in the Finder and and then drop it into the Library Scripts Internet Services folder, information technology shows up like this in the Script Menu. The new script behaves just similar the born ones: all you demand to do is click it in one case to run it.

Luckily, you lot tin override the Script Menu and put scripts into whatever folders yous'd like. To motion some scripts from one Script Menu category to another, simply open the Library Scripts folder, and elevate the scripts into a unlike subfolder (Figure 1-8).

Annotation

Your scripts don't have to be inside a subfolder at all; if you'd like, you tin can but exit them floating in the Library Scripts binder. That mode, they'll appear directly in the Script Bill of fare—yous won't accept to navigate through submenus to become to them .

Effigy 1-9. Here, the Navigation scripts (everything from New Applications Window to Open Special Window) were moved into the Finder Scripts subfolder. Then, the Navigation Scripts binder was deleted, leaving a Script Menu like this. You might want to merge the scripts from other folders, also. The kickoff two scripts in Nuts might fit ameliorate in the URLs submenu, for example, while the last script from Basics might fit meliorate in the Script Editor Scripts submenu.

Working with the Scripts You Accept

As you'll apace realize from using the Script Carte, your Mac is teeming with dozens of free, built-in scripts. You tin run, rename, and organize these scripts, as described on the preceding pages.

Merely if you're only starting to learn AppleScript, these scripts can be lifesavers. Not simply can you examine how the scripts work, but you tin also make changes and see how they touch the scripts' beliefs. Best of all, if you get stuck when writing a new AppleScript, you tin copy some of the code from the Script Card'due south scripts and paste that code right into your own script.

Opening a Script

The commencement pace in working with a script, of course, is opening it upward. Fortunately, this is an like shooting fish in a barrel process: just double-click the script in the Finder. The script opens in Script Editor, the all-purpose AppleScript plan described in Chapter 2.

When you're simply learning AppleScript, you might as well start by looking at a unproblematic script. Double-click Library Scripts Navigation Scripts New Application Window.scpt, and Script Editor opens the script file in a new window (Figure 1-9).

Figure one-ten. If you've never seen an AppleScript before, you may exist surprised at how simple the code looks. As you can probably gauge from the commands in the window, this script simply opens the Applications folder in the Finder.

At this point, you can click the Run button to meet what the script actually does (in this case, the script opens a new Finder window and takes yous to the Applications binder).

Analyzing How It Works

The next step in working with a script, of class, is agreement how the script actually works. Some commands are self-evident, while others crave you to examine a program'south lexicon— its primary command list (Section iii.2.2)—to sympathize exactly what'southward going on. Luckily, the commands in the New Applications Window script are all pretty simple:

  • tell application "Finder " instructs Mac Os 10 that the commands that follow should be run by the Finder.

  • activate brings the Finder to the front, much as you would by clicking its Dock icon. Unlike clicking the Dock icon, still, the activate command doesn't automatically open up a new Finder window; for that stunt, you'll need the next command.

  • open binder "Applications" of the startup deejay tells the Finder to open a new window, displaying the Applications folder of your primary hard drive. (If you already have the Applications folder open up, this command simply brings that window forward.)

  • end tell directs the Finder to go nearly its regular business, ignoring further AppleScript commands.

Changing What It Does

Now that you understand how the script works, you lot tin change it to ameliorate suit your needs. To make the script open up the Users binder, for instance, you'd follow this process:

  1. Replace Applications with Users .

    File names have to be surrounded in double quotes, then make sure you don't delete the quotation marks.

  2. Click the Run button to exam your script .

    Y'all should see the Finder come forward and display the Users binder.

  3. Choose File Save As (Shift- -S) .

    Name the file New Users Window.scpt, brand sure the File Format is set to Script, and save it in the Library Scripts Navigation Scripts binder.

  4. Open your Script Menu, and run your new script from the Navigation Scripts submenu .

    If you lot did everything correctly, your new card item opens the Users folder in the Finder (Figure 1-ten).

Figure i-11. When you run your newly edited script (height left), yous see your Users binder (bottom right). The house icon represents the account that'south currently logged in.

Applescript Editor 2.0 Download Mac

Posted by: maclintasaddeepled.blogspot.com

Post a Comment for "Applescript Editor 2.0 Download Mac Updated"