If my understanding is correct, there are two types of content that can be copied to the Mac global (systemwide) clipboard:
text
or
file
Even though they are two different, discrete data types, they share the very same clipboard. For example, if you have an image file
on your clipboard, and then you copy a text
sentence, the sentence will overwrite the image file, and vice versa. Please correct me if I am wrong.
My question is, how can I determine if the clipboard does not contain text
, using AppleScript?
The context of my question is an AppleScript .scpt file that speaks the selected text in the System Voice at a specified volume. The selected text is copied to the clipboard, and then the text is spoken via the say
command. The script is triggered by keystroke via FastScripts.app.
Every so often, I am given an error dialog that states, "Error Number: -1728." This error occurs when, instead of text
being highlighted, I have highlighted or selected an actual file
. Mac's Speech function cannot speak a file
; Speech can only verbalize text
.
So, I would like to create an if...then
statement in my script to catch this error. Ideally, I would then like to convert the file
to text
, if possible in the way that TextEdit does.