How to get selected text??

One important feature I as a newbie to applescripting cannot figure out is how to get a script to work on text that is simply highlighted in a program (i.e., not yet copied to the clipboard or the like). (I’m specifically interested in being able to run a script based on some text highlighted on a contact in Entourage.)

Does the implementation of this vary from program to program? Where in the dictionary would this information be anyways?

thanks in advance,

Support for the selection is, indeed, application specific. The application has to support the ‘selection’ object.

In this case, Microsoft Entourage does support ‘selection’, so you’re partly in luck:

[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

However, this returns either the currently selected folder, message, or text, depending on context, so you need to check the result to make sure it’s what you expect.