Here is a piece of a script that I am currently using:
activate application "Mail"
tell application "System Events"
tell process "Mail"
keystroke "c" using {command down}
end tell
end tell
This is fine if the program in which text is highlighted (selected) is Mail. I would like to make the script more useful. I need to be able to copy to the clipboard the text that is selected, despite the program in which it is selected (perhaps it is Safari, Mail, or Pages, etc)
From there the remainder of my script (no shown here) will paste the clipboard contents and manipulate it. (This part of the script is working ok.)
If no text is selected and the script is executed, I have used a try / on error / end try block to create an alert, however I would also like to know what script command to use to cause a script to terminate. Thanks