The Entourage User's Weblog has been relocated.

You should be automatically redirected to the new location in 5 seconds. If not, please click on the link below.
Please remember to update your web browser bookmarks.

This page has been moved to

http://www.barryw.net/weblog/files/use_scripts.html.

content="text/html; charset=iso-8859-1" /> The Entourage User's WebLog
Installing and Using Scripts
Scriptability is one of the great features of Entourage. It allows every user to make Entourage work in ways they want it to and to add new features, without causing th eapplication to become bloated beyond all use and sense. But, the average user doesn't use any scripts, which is a great shame because they are missing out on so many adbantages. All too often, when a script solution is proposed on the newsgroups, the person with the problem responds with words to the effect "I'm a complete novice with scripts, and I don't understand what to do..."

Well, here's hoping that this article will explain how to get scripts, install then and use them in a way that is clear enough for users of all abilities.

First, catch your script...

(With apologies to Mrs Glass)

Before you can use a script, you need to have one. There's three basic ways to catch your script.

You could download one. There are some good places for scripts. I have a few of mine
here, there are many more at the ScriptBuilders web site. There are scripts providing all kinds of additional functionality available. Take a while to see if there is anything there to suit your needs. If you download a script frm either of these places it will most likely be in the form of a 'Compiled Script' - this is a file format that is useable directly by Entourage.

Or, you could ask on the
newsgroup or mailing list. There are some experts hanging out in those places, and if a script solution is most applicable, they will either point one out to you, or may write one and post it in reply. These scripts will be in text form, usually pasted into the body of the message. This will need to be 'compiled' before it can be used. More on that later.

Finally, you could write your own! This isn't as difficult as it sounds. There are plenty of resources available, either on the web or in book form. If (when?) you get stuck, you can ask on the newsgroups mentioned earlier - there are always people there willing to help out.

So, let's assume you have caught your script now, and move n to steo two...

Step Two - Compiling...

If you have downloaded a script, and in the Finder it is described as "Compiled OSA Script (Data Fork)" then all is well, you can skip this step.

Otherwise, lets assume that you have copied the script from an email message. Lets pretend that this is the script you found (it will permanently delete selected messages without leaving them in the Deleted Items mail folder):

tell app "microsoft entourage"
set theMessages to current messages
delete themessages
try
delete themessages
end
end

You now need to make a script from it. First open up "Script Editor" - this is the application that Apple provides for writing, compiling and saving scripts. Find it in the "Applescript" folder of your "Applications" folder. Script Editor should start up with a new empty window. Copy the lines containing the script and paste them into the script window. Click on the 'Compile' button and the script should become nicely formatted like this:

ScriptWindow
It is possible that the Script Editor will throw an error at this stage - maybe because the original writer made a syntax error, but more likely because the mail client or list server put a line break into the script. The part of the script throwing the error will be highlighted in the script window and it is usually fairly obvious where the line break has occurred - just remove the line break and re-compile. Occasionally, the line break will occur at a point where it doesn't immediately throw an error, and the highlighted text may be on the line below the real error - again, this is usually fairly easy to spot, just by reading the script. Don't worry, you'll very quickly get used to spotting these errors in supplied scripts, even if you can't write your own scripts!

Saving The Script

Having successfully compiled the script, you now need to save it. The best place to put it is in Entourage's special scripts folder. In the script Editor window, select 'Save' (or 'Save As...') from the file menu. Type in a suitable name for the script (I used "Full Delete for this example). The 'File Format' drop down should default to "script" which is what you want. Leave all the other options alone, like this example:

ScriptSave

Now, navigate first to your 'Documents' folder, then to the 'Microsoft User Data' folder, then to a folder in there called 'Entourage Script Menu Items' and click the 'Save' button.

scriptMenu2
If you got things right, the script is saved as a 'Compiled Script' and will appear in Entourage's Script menu (the little black 'scroll' icon just to the right of the 'Help' menu) as shown in the partial screen shot here. This script can then be easily accessed at any time directly from within Entourage, without having to resort to the Script Editor application ever again! You can now quit Script Editor, and we'll move on to the next section, how to use the script.

Running the script

In its simplest form, you can just run the script by selecting it from the script menu as I described above. But, there are other options. The example I used needs you to select some messages first, then run the script (and they will be permanently removed form Entourage, so select some messages you don't want any more if you intend to try the script!). But, there are other options...

You can, if the script is a suitable one, set up a schedule to run a script automatically at some predefined time. Use of schedules is fairly straightforward, select 'Schedules' from the Tools menu, click on the 'new' button and explore the timing options under the 'When' section. In the 'Action' section, you can set the schedule to 'Run AppleScript', as in this example:

schedule

When you click the 'Script...' button, you can select any script on your system, it doesn't have to be in the Script Menu Items folder, but this is still the best place to put scripts as they can then also be run manually.

In a similar manner, you can set a script to run as the action to a rule. For example, with the sample script just created and saved earlier, you could set up a rule to permanently delete any messages from a particular sender that you no longer want anything to do with. Simply set up your selection criteria to match whatever messages you want to kill, and set the rule action to run the script. You'll never see the messages again, they'll be completely deleted as they arrive!

They're the three basic methods to run a script in Entourage, but there's more...

Using Keyboard Commands


scriptMenu
Once a script is in the Script Menu Items folder, you can easily assign it a keyboard shortcut. Go back to the partial screen shot of the Entourage Script Menu earlier in this article - notice how 'Insert Firefox URLs' and 'Insert Notes' have keyboard commands next to them? These scripts can be called with a keyboard command, just like many other menu items (Command-Control-U and Command-Control-N in these cases). Assigning keyboard commands is easy. You just use a particular 'code' at the end of the script name when you save it to define the keyboard command. In the case of 'Insert Firefox URLs', the script was saved with the name "Insert Firefox URLs v1.0\cmU.scpt" Entourage ignores the '.scpt' extension anyway - that will never appear in the Entourage menu. Then, Entourage uses the '\cmU' at the end of the name proper to define the keyboard shortcut. the '\' declares the existence of the shortcut. the 'c' defines the Control Key modifier, the 'm' the Command Key modifier and the 'U' the actual key to use with the modifier. So, '\cmU' is understood by Entourage to mean Control-Command-U, and that symbol is put in the script menu to the right of the script name. The modifiers you can use in this way (either singly, or in combination) are:
  • \c - Control Key
  • \m - Command Key
  • \o - Option Key
  • \s - Shift Key

So, you can now change the name of our example script to "Full Delete\csF.scpt" in the Finder. Next time you select the Script menu in Entourage, you will see the symbols for Control-Shift-F have been added to the script's name in the list. The Full Delete script can now be run just by selecting some messages and hitting Control-Shift-F. Easy.

Just one warning with keyboard shortcuts - if you happen to define one that is used elsewhere in Entourage, the script will over-ride the 'standard' shortcut. So, if you defined a script to use Command-R, for example, the script would run just fine with this command, but you could never again use Command-R to reply to a message! For this reason, I tend to use the Control key in all my script keyboard shortcuts - the Control key isn't used by the system or the Entourage application for keyboard shortcuts, so you're pretty safe from conflicts.

There's more information on using keyboard shortcuts at the Entourage Help Page web site here.


Please feel free to leave a comment using the links below - comments on this article or requests for future articles are always welcome and will be responded to where appropriate.
|