On Mar 26, 2012, at 3:40 PM, theDaniel wrote: How can I find if there is something on the clipboard in SL and Lion?
The command “clipboard info” tells you what types are available on the clipboard and what sizes they are. You can also ask for specific types and get back the info for the data of that type.
clipboard info for Unicode text
All three of the clipboard commands are implemented as scripting additions and the “clipboard” property is not typically implemented by any applications. Nevertheless, the clipboard commands all use “the clipboard” so that an application property could avoid the “the” and peacefully coexist, like in BBEdit.
clipboard info [for <type>] the clipboard [as <type>] set the clipboard to <anything>
Most applications copy multiple representations of the selected data to the clipboard, allowing receiving applications to choose the best type for their needs. That’s why it’s very handy to be able to specify which data type you want to deal with in your scripts.
An interesting technique that I use is the simple shell script: “pbpaste | pbcopy” which basically strips the clipboard of everything except text (in utf8 and utf16 flavors, apparently). If you do this at the beginning of your script, you will remove any images.
do shell script "pbpaste | pbcopy"
This can be used to remove styles as well as images.
Jon
|