• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Clipboard and Entourage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Clipboard and Entourage


  • Subject: Re: Clipboard and Entourage
  • From: Christopher Nebel <email@hidden>
  • Date: Mon, 29 Aug 2005 18:35:23 -0700

On Aug 29, 2005, at 12:39 PM, Matt Neuburg wrote:

I have found that MS Word needs the clipboard as text, otherwise it
won't accept it. Maybe Entourage is the same in this.

Try pasting the result of:
--
set the clipboard to "Some stuff" as text
--
into Entourage.

I'm still not understanding the problem or the proposed solution. There is
no "as" parameter to "set the clipboard", and "some stuff" *is* text. Nor am
I able to see the circumstances under which Entourage's clipboard fails to
get set. This works for me:


tell application "Microsoft Entourage"
    activate
    set the clipboard to "some stuff"
end tell

I can then paste "some stuff" into Entourage. So I'm just not getting what
just happened in this thread.

The difficulty lies in the various "flavors" (yes, that's the technical term) of clipboard data and a somewhat too-literal interpretation of them. Here's the deal:


When you want to put something on the clipboard, it's common to put it on in a number of different flavors. For instance, an application might decide to put editable text on the clipboard as both text and as a rendered image of that text. To get more concrete, when you copy an item in the Finder, it puts the item name, a path to that item, and the item's icon on the clipboard. Styled text on the clipboard is actually represented as two flavors: one for the plain text, and another for the style information (which naturally isn't much use without the text, but there you are). Clients can then choose the flavor that they consider "best", whatever that happens to mean in their context.

That's the background; now it gets tricky: old-style text ('TEXT') and Unicode text ('utxt') are considered different clipboard flavors (in addition to being distinct AppleScript types). When you say "set the clipboard to ...", it puts precisely that flavor of data on to the clipboard. (More precisely, the Apple event representation of that type.) For strings, that's 'TEXT' flavor (plus maybe 'styl'); for Unicode text, that's 'utxt'. Therefore...

set x to "some stuff" -- x is of type 'string'
set the clipboard to x -- clipboard now contains 'TEXT' (and nothing else!)


set x to "some unicode" as Unicode text
set the clipboard to x -- clipboard now contains 'utxt' (and nothing else!)


You (matt) effectively did the former, Jay the latter. Sufficiently old or ill-behaved applications such as Entourage do not understand 'utxt' flavor, and therefore don't see any paste-able data and disable their "paste" command.

The solution is therefore to manually put the flavor that Entourage expects, namely 'TEXT', which you can do by saying "x as string". (This works in the "set the clipboard" command despite the fact that "as" isn't a parameter for "set the clipboard" because AppleScript *knows* that "as" isn't a parameter for "set the clipboard" and interprets the "as" as the "as" operator, not an "as" parameter. Say that three times fast.)

It's also possible to set the clipboard to more than one flavor by setting the clipboard to a record, where the keys are the desired flavors. (You should ensure that the flavor key matches the data!) For instance:

set x to do shell script "perl -e 'print \"smile! \\x{263a}\"'" -- Unicode-only niftiness
set the clipboard to {Unicode text: x, string: x as string}


Now Unicode-aware apps will get the whole smiley text, while non- aware apps will get, well, as much as they can.


--Chris Nebel AppleScript and Automator Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Clipboard and Entourage
      • From: Paul Berkowitz <email@hidden>
    • Re: Clipboard and Entourage
      • From: Matt Neuburg <email@hidden>
References: 
 >Re: Clipboard and Entourage (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: choose remote application - is this thing on?
  • Next by Date: Re: Clipboard and Entourage
  • Previous by thread: Re: Clipboard and Entourage
  • Next by thread: Re: Clipboard and Entourage
  • Index(es):
    • Date
    • Thread